DES Weak Keys - Double Encryption I know there are 4 known weak keys, their value and that double encryption using one of the weak keys should give back the plain text.

I implemented this in OpenSSL. I have a plain text $m$ in a file plain.txt and compute $y = DES_k(m)$ where $k$ is a weak key. Then I compute $y' = DES_k(y)$. Instead of getting $m$ I get only a portion of it and the rest is part of $y$.

Why is this happening?
If you don't get the expected result, then you are doing it wrong; most probably, use wrong mode of operation and/or wrong padding. You can get the expected result with openssl as

openssl enc -e -des-ecb -in plain.txt -out cipher1.txt -nopad -K 0101010101010101 -iv 0
openssl enc -e -des-ecb -in cipher1.txt -out cipher2.txt -nopad -K 0101010101010101 -iv 0


plain.txt file size should be multiple of 8 (8 bytes is DES block size), and plain.txt and cipher2.txt files should be identical.