码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2017-05-19 19:26:09      阅读:646      评论:0      收藏:0      [点我收藏+]

标签:repo   stream   padding   clear   read   ecif   strong   origin   stat   

 //解密數據
            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);
                        }
                    }
                }
            }

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

标签:repo   stream   padding   clear   read   ecif   strong   origin   stat   

原文地址:http://www.cnblogs.com/kzwrcom/p/6879853.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!