public static byte[] Decrypt(EncryptedObj data) { var keys = AESEncryption.GetKeys(data.VectorData); var str = AESEncryption.DecryptStringFromBytes_Aes(data.EncryptedData, keys.Key, keys.IV); var res = Convert.FromBase64String(str); return(res); }
public static EncryptedObj Encrypt(byte[] data) { AesManaged aes = new AesManaged(); var keys = AESEncryption.GetKeys(aes.IV); var str = Convert.ToBase64String(data); var res = AESEncryption.EncryptStringToBytes_Aes(str, keys.Key, keys.IV); return(new EncryptedObj { VectorData = aes.IV, EncryptedData = res }); }