Skip to content

Instantly share code, notes, and snippets.

@awswithdotnet
Created March 3, 2022 19:21
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/59c650ffb638de5aa0139ffe1fa158dc to your computer and use it in GitHub Desktop.
Save awswithdotnet/59c650ffb638de5aa0139ffe1fa158dc to your computer and use it in GitHub Desktop.
kms Crypto AESDecrypter Decrypt Partial 2
string plainText = String.Empty;
byte[] byteData = Convert.FromBase64String(encryptionPackage.CipherText);
using (Aes aes = Aes.Create())
{
using (MemoryStream memoryStream = new MemoryStream(byteData))
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, aes.CreateDecryptor(key, _iv), CryptoStreamMode.Read))
{
using (StreamReader streamReader = new StreamReader(cryptoStream))
{
plainText = streamReader.ReadToEnd();
}
}
}
}
return plainText;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment