A repeating key XOR encryption uses a key that is longer than one byte in size and is repeatedly used to encrypt the entire plain text.
XOR encryption is symmetric encryption that uses the same key to encrypt and decrypt the message. It secures communication between two endpoints by XORing plain text with the key.
Note: To read more about XOR encryption, click here.
We'll assume that the text is written in English, and will use letter frequency to break the XOR encryption. To crack repeating key XOR encryption, we must understand how breaking a single byte key XOR encryption works.
To break XOR encryption, we need to figure out two things:
To find the key size, we'll use the brute force method. Either we can keep guessing the size of the key linearly or randomly. For each key size, calculate its
To calculate the Hamming distance:
Note: We can calculate the hamming distance by XORing the two strings and counting the number of ones in the resulting string.
Let's look at an example below to understand the calculation of Hamming distance in step 1:
The diagram below demonstrates calculating the Hamming distance between block one and block two in detail:
Now that we have the top three key sizes, repeat the following procedure for all key sizes:
The illustration below depicts the steps with a key size of three:
Decrypt the text and give it a score on the basis of alphabet recurrence using letter frequency.
The key that achieves the highest English score is most probable to be the encryption key.
Free Resources