I got two 8-byte strings.

One which is decrypted is:


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.

  • $\begingroup$ What you are looking for is a "known plaintext" attack on DES (and even more probably a "chosen plaintext" attack. $\endgroup$
    – xanatos
    Oct 30, 2011 at 9:50
  • $\begingroup$ 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. $\endgroup$ Oct 31, 2011 at 14:11
  • $\begingroup$ I'll have to disagree with @PaŭloEbermann. This question is a decryption challenge, thus not on topic. The linked Meta discussion in there gives an explanation on why that is so. Maybe if you tried to attack the problem on your own, then tell us about your progress and where you got stuck, and ask a question about that. $\endgroup$
    – rath
    Aug 11, 2013 at 22:05
  • 1
    $\begingroup$ @rath Ah, someone caught my standard comment ... I agree that it might not be "fully" on topic. The goal of my comment was to get the asker register his account here. As he didn't do this in almost two years, it is improbable that he'll now add details. $\endgroup$ Aug 12, 2013 at 8:06
  • $\begingroup$ I didn't notice the age of the post, it just popped up after the latest edit. $\endgroup$
    – rath
    Aug 12, 2013 at 10:49

2 Answers 2


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.


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.