欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > C# >内容正文

C#

C# Aes CryptoStream Specified padding mode is not valid for this algorithm的解決方法

发布时间:2024/10/12 C# 132 豆豆
生活随笔 收集整理的这篇文章主要介绍了 C# Aes CryptoStream Specified padding mode is not valid for this algorithm的解決方法 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

 //解密數據
            using (var ss = File.OpenRead(@"d:\qq.d.flac"))
            {
                using (FileStream w = new FileStream(@"d:\qq.flac", FileMode.Create))
                {
                    using (var cs = AesStream.StreamDecrypt(w, "qq"))
                    {
                        ss.Seek(0, SeekOrigin.Begin);
                        for (int i = 0; i < ss.Length; i += 4096)
                        {
                            byte[] chunkData = new byte[4096];
                            int bytesRead = 0;

                //Updates the underlying data source or repository with the current state of the buffer, then clears the buffer.
                            if (!cs.HasFlushedFinalBlock)
                            {
                                cs.FlushFinalBlock();
                            }
                            bytesRead = ss.Read(chunkData, 0, chunkData.Length);

                            if (i > 4096*1024)
                            {
                                break;
                            }
                            cs.Write(chunkData, 0, bytesRead);
                        }
                    }
                }
            }

转载于:https://www.cnblogs.com/kzwrcom/p/6879853.html

总结

以上是生活随笔为你收集整理的C# Aes CryptoStream Specified padding mode is not valid for this algorithm的解決方法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。