110,561
社区成员
发帖
与我相关
我的任务
分享
static void AesEncrypt(Aes aes, Stream inStream, Stream outStream)
{
using (var cryptoStream = new CryptoStream(inStream, aes.CreateEncryptor(), CryptoStreamMode.Read))
{
cryptoStream.CopyTo(outStream);
}
}
static void Main()
{
Aes aes = ...;
using (var 输入流 = File.OpenRead("要加密的文件"))
using (var 输出流 = File.Create("结果文件"))
{
AesEncrypt(aes, 输入流, 输出流);
}
}
public static Byte[] encrypt(Byte[] data, Byte[] key)
{
RijndaelManaged provider_AES = new RijndaelManaged();
provider_AES.KeySize = 128;
ICryptoTransform encrypt_AES = provider_AES.CreateEncryptor(key, key);
byte[] output = encrypt_AES.TransformFinalBlock(data, 0, data.Length);
return output;
}