Why can't I use two DES keys that differ only in the OpenSSL ratio?

When I perform the following action in the terminal, I get a different decryption text compared to the message showing that these keys are matched with a unique encryption

openssl enc -des-ecb -in text.in -out cipher.txt -k '96508092' openssl enc -d -des-ecb -in cipher.txt -out text.in -k '82514145' 

But when I implement it when programming using <openssl/des.h> , Crypto.cipher, pyDes, I got the same decrypted text. I found why I get the same text, and that is because these 8-byte keys are mapped to the unique 7-byte key 0x3832343134313401. See My previous question. Why can I encrypt data with one DES key and successfully decrypt with another?

My question is: how is it implemented in OpenSSL terminal commands in different ways compared to the mentioned libraries, that it can match these 8-byte keys with unique encryption?

0
python algorithm openssl encryption pyopenssl
source share
1 answer

You need to use the capital letter -K if you want to specify key bytes. Otherwise, OpenSSL accepts its password and derives from it a (different) key.

You also need to use the hexadecimal version of the keys:

 openssl enc -des-ecb -in text.in -out cipher.txt -K '3832353134313435' openssl enc -d -des-ecb -in cipher.txt -out text.out -K '3933353035303434' 
0
source share

All Articles