C# Decrypting AES/ECB Paddded Using PKCS#5

♀尐吖头ヾ 提交于 2019-12-24 11:53:24

问题


I'm making a small application for fun in C# which retrieves a image from a server which is encrypted using AES/ECB with a single synchronous key (which I know) and padded using PKCS#5.

I tried just downloading the image by using a BinaryReader, however when I go to open the image, it is a corrupt file. I assume this is because it is encrypted. Here is my code:

string repsonseData = string.Empty;
using (var response = (HttpWebResponse)req.GetResponse()){
   using (var reader = new BinaryReader(response.GetResponseStream())) {
     Byte[] lnByte = reader.ReadBytes(1 * 1024 * 1024 * 10);
      using (FileStream lxFS = new FileStream("imageName.jpg", FileMode.Create)) {
         lxFS.Write(lnByte, 0, lnByte.Length);
      }
   }
}

Any help would be appreciated. Thanks!

来源:https://stackoverflow.com/questions/21022086/c-sharp-decrypting-aes-ecb-paddded-using-pkcs5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!