Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 3, 2022 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awswithdotnet/119cd41c34f6677a599216da780289de to your computer and use it in GitHub Desktop.
Save awswithdotnet/119cd41c34f6677a599216da780289de to your computer and use it in GitHub Desktop.
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