DES Initialization Vector in C# [duplicate]
I am trying to decrypt (using the DES algorithm) d开发者_如何学Goata that comes from a third party in C# code. There are plenty of examples here and elsewhere that have helped me out. The problem is that I don't know what to use for the 'initialization vector'.
The third party supplied a tool for use on the command line (DES.EXE, which I believe is an out-of-the-box build of the libdes library v4.01) which only requires that you supply an encryption key. So, I can decrypt fine with the tool. However, I would rather not spawn a process to run the tool from my code.
My question is how do I generate/find that initialization vector. I am 99.9% sure it can be done from looking at other posts but I can't figure it out. I talked to the third party and they said they do not support that approach. Any help would be greatly appreciated.
You probably don't have an initialization vector. Just pass in null an array of zero's for the initialization vector for CreateDecryptor:
byte[] iv = new byte[] {0, 0, 0, 0, 0, 0, 0, 0};
des.CreateDecryptor(key, iv);
Edit: I was wrong, it's an zero IV, not null.
精彩评论