相关疑难解决方法(0)

C# AES:加密文件会导致“要加密的数据长度无效”。错误

我有一个PDF文件。
当我想使用下面的代码对其进行加密时,Length of the data to encrypt is invalid.发生了错误:

  string inputFile = @"C:\sample.pdf";
  string outputFile = @"C:\sample_enc.pdf";

  try
  {    
    using (RijndaelManaged aes = new RijndaelManaged())
    {
      byte[] key = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
      byte[] iv = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

      aes.Key = key;
      aes.IV = iv;

      aes.Mode = CipherMode.CFB;
      aes.Padding …
Run Code Online (Sandbox Code Playgroud)

c# encryption aes rijndael

2
推荐指数
1
解决办法
3670
查看次数

标签 统计

aes ×1

c# ×1

encryption ×1

rijndael ×1