# Decrypting DES with decrypted and encrypted data

I got two 8 bytestrings One which is decrypted is: FF FF FF FF FF FF FF FF and one which is encrypted is: 16 05 78 B0 0A C2 78 7F

Encryption mode is CipherMode.ECB

I need the key used in DES encryption.

-
 What you are looking for is a "known plaintext" attack on DES (and even more probably a "chosen plaintext" attack. – xanatos Oct 30 '11 at 9:50 Welcome to Cryptography Stack Exchange. Your question was migrated here because of being not directly related to software development (the topic of Stack Overflow), and being fully on-topic here. Please register your account here, too, to be able to comment and accept an answer. – Paŭlo Ebermann♦ Oct 31 '11 at 14:11

## migrated from stackoverflow.comOct 31 '11 at 11:05

As far as I know, there is no known practical attack on DES which is faster than brute force. (There are some listed in Wikipedia, but they require a really large number of chosen or known plaintexts (and the corresponding ciphertexts).)

As DES has an effective key size of only 56 bits, i.e. there are $2^{56}$ different keys, brute force is actually feasible, and one block of plaintext+ciphertext is all which is needed for this.

In principle, you would have to calculate $C_K = DES(K, P)$ for all possible keys until you got one with $C_K = C$ (your known ciphertext). (Alternatively, do $P_K = DES^{-1}(K, C)$ for all keys until $P_K = P$, whichever is easier for you.)

Have a look at the EFF DES Cracker article on Wikipedia for one machine which was used for this, and on the Brute force attack section of the DES article, too.

-

Do you know anything at all about the key? If not, then what you have is a "Known plaintext attack" - you know the cyphertext is 16 05 78 B0 0A C2 78 7F and the plaintext is FF FF FF FF FF FF FF FF.

DES has some weaknesses, but it isn't that weak. A cypher that can be cracked with a mere 8 bytes of plaintext/cyphertext would be very weak indeed.

Can you generate more cyphertext/plaintext pairs if you want to? That might allow you to use linear attacks and differential attacks.

Apart from that, you will have to try to brute force all possible keys and see which one works.

-