Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 3, 2022 19:13
Embed
What would you like to do?
kms Crypto AESEncrypter Partial 2
using (Aes aes = Aes.Create())
{
ICryptoTransform cryptoTransform = aes.CreateEncryptor(plainTextKey, _iv);
using (MemoryStream memoryStream = new MemoryStream())
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write))
{
using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
{
await streamWriter.WriteAsync(plainText);
}
encryptedData = memoryStream.ToArray();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment