Can someone explain the difference in openssl cli and c++ DES output

216 Views Asked by At

Using openSSL, a program of mine is producing different encrypted output than openSSL's command line utility. Using 'aaaaaa' as plain text and 'A' as the key, I've been running

openssl enc -des -e -nosalt -in test1.txt -out test1out.txt

to get a sample encryption, but my sample program (http://pastebin.com/e4P0DGYR) never produces the same hash.

To run the sample program, enter

./a.out 40 42 $(hexdump -ve '1/1 "%.2x"' test1.txt) $(hexdump -ve '1/1 "%.2x"' test1out.txt)

I used this (http://www.codealias.info/technotes/des_encryption_using_openssl_a_simple_example) as an example.

1

There are 1 best solutions below

2
On BEST ANSWER

As someone answered when you posted this on the openssl-users mailing list, the CLI uses ECB mode and the program uses CFB mode. DES-ECB isn't the same as DEC-CFB (or any other mode).