问题
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