【发布时间】:2021-01-22 19:19:38
【问题描述】:
多年来,我一直在 .NET 框架中使用 AES 进行 256 位加密。我最近在 .NET Core 5 中启动了一个新项目,并不断收到错误消息,指出此安装仅支持 128 位密钥。经过一番研究,.NET Core 现在似乎只支持 128 位密钥。
我的问题是我已经有大量使用 256 位的 AES 加密的数据。我可以使用 .NET Core 中的替代方案吗?不同的图书馆?一个不同的包,这样我就不必解密和重新加密我所有的现有数据?
//--------------------------------------------------------------------------
//Perform the encryption
//--------------------------------------------------------------------------
try
{
//Initialize the RijndaelManaged object
rmAES = new RijndaelManaged { BlockSize = 256, Key = key, IV = iv, Padding = PaddingMode.PKCS7 };
//Encrypt the data to the memory stream using the CryptoStream snd StreamWriter
ICryptoTransform rmEncryptor = rmAES.CreateEncryptor(key, iv);
rmMS = new MemoryStream();
using CryptoStream rmCStream = new CryptoStream(rmMS, rmEncryptor, CryptoStreamMode.Write);
using StreamWriter rmSWriter = new StreamWriter(rmCStream);
rmSWriter.Write(sourceString);
rmSWriter.Close();
}
catch (Exception ex)
{
throw new Exception(ex);
}
【问题讨论】:
标签: encryption .net-core aes rijndael rijndaelmanaged