The challenge#

Here is the opening stanza of an important work of the English language:

Burning 'em, if you ain't quick and nimble
I go crazy when I hear a cymbal

Encrypt it, under the key "ICE", using repeating-key XOR.

In repeating-key XOR, you'll sequentially apply each byte of the key; the first byte of plaintext will be XOR'd against I, the next C, the next E, then I again for the 4th byte, and so on.

It should come out to:


Encrypt a bunch of stuff using your repeating-key XOR function. Encrypt your mail. Encrypt your password file. Your .sig file. Get a feel for it. I promise, we aren't wasting your time with this.

The solution#

💭 This should be simple. We already know how to XOR bytes, it's just a matter of looping through the plaintext bytes and XOR them using the key bytes sequentially. And of course show the hex representation of the final XOR'd string.



  • Initial attempt did not result in the expected. I realized, single digit hex numbers should be zero-padded. That was a good realization but it did not fix the problem.
  • I had forgotten to increment keyIndex. Doing keyIndex++ fixed it.
  • In cryptography, we are always working with a black box. There is almost no telling whether we are getting closer to a solution or not. A single character makes a difference of day and night, and there is no difference between a single character mistake and a thousand characters mistake.
Tweet this | Share on LinkedIn |