I spent some time (~ 2 days) to deal with the same problem. "Rewriting" des.exe in C #. In the end, I got the libdes sources and reconstructed the logic.
The initialization vector is all (8) zeros. That is, a new byte [8].
However, as a rule, you can convert a string password into an 8-byte long key. If you use simple DES (not Triple DES), this code may do the trick for you:
public class LibDesPasswordConvertor { public byte[] PasswordToKey(string password) { if (password == null) throw new ArgumentNullException("password"); if (password == "") throw new ArgumentException("password"); var key = new byte[8]; for (int i = 0; i < password.Length; i++) { var c = (int)password[i]; if ((i % 16) < 8) { key[i % 8] ^= (byte)(c << 1); } else {
(Some pieces of libdes code were reused, although I had to determine part of the DES checksum myself.
The final error is that libds uses a non-standard padding mechanism. It's almost like an ISO, but the last byte is not the number of bytes added, but 8 is the number. I set the Padding property to None and handled the pad myself.
source share