public CryptApi(X509Certificate cert, Byte[] clearData) { clearkey = CATools.GetCypherKey(); encryptedKey = Convert.ToBase64String(CATools.AsymmetricEncrypt(cert, Encoding.UTF8.GetBytes(clearkey))); clearDataHash = CATools.SHA1Checksum(clearData); encryptedData = CATools.Encrypt(clearData, clearkey); }
public CryptApi(X509Certificate cert, Byte[] encryptedData, String encryptedKey) { this.encryptedKey = encryptedKey; this.encryptedData = encryptedData; Byte[] k = Convert.FromBase64String(encryptedKey); if ((k == null) || (k.Length <= 0)) { throw new Exception("Encrypted key is empty"); } clearkey = Encoding.UTF8.GetString(CATools.AsymmetricDencrypt(cert, k)); clearData = CATools.Dencrypt(encryptedData, clearkey); clearDataHash = CATools.SHA1Checksum(clearData); }