我正在寻找一种无需获取OutOfMemoryException
即可从文件中解码很大(1.5Gb)base64字符串的方法。我尝试使用this方法进行编码。
你能建议我一种方法吗?
提前谢谢!
编辑:
密码:
public static string HighLevelEncryptionAES(byte[] plainDataBytes, byte[] keyBytes)
{
CryptoSecurityClass cryptoSecurity = new CryptoSecurityClass();
AesCryptoServiceProvider serviceProvider = cryptoSecurity.GetAesProvider(keyBytes);
ICryptoTransform encryptor = serviceProvider.CreateEncryptor();
byte[] encryptedBytes = encryptor.TransformFinalBlock(plainDataBytes, 0, plainDataBytes.Length);
string encryptedString = Convert.ToBase64String(encryptedBytes);
return encryptedString;
}
AES提供程序类:
private AesCryptoServiceProvider GetAesProvider(byte[] key)
{
return new AesCryptoServiceProvider()
{
KeySize = 256,
Key = key,
BlockSize = 128,
Padding = PaddingMode.PKCS7,
Mode = CipherMode.ECB
};
}