Challenges
Unknown key length
Cryptography
Hard
Hamming distance and Kasiski
Solves: 9
Unknown key length
Author: CyberSamSU
Points
85
Now there is no help at all: both the key and its length are unknown. This is the complete classic challenge of breaking a repeating-key XOR cipher (the famous "Break repeating-key XOR" from the Cryptopals set).
The solution consists of two steps:
- Finding the key length. For each
L = 2..40, calculate the Hamming distance (the number of differing bits) between consecutiveL-byte blocks of the ciphertext and divide it byL. TheLthat gives the smallest result is highly likely to be the key length. - Recovering the key. Divide the ciphertext into
Lcolumns and solve each column as a separate single-byte XOR — try 256 keys and score the result (plus for spaces and lowercase letters, large minus for non-printable bytes).
The ciphertext is in the attached file, in base64 format: shifr.b64. The text is in Uzbek, with many spaces.
Hamming distance: bin(a ^ b).count('1') — gives how many bits differ in two bytes. For accuracy, do not take just one, but take at least 4 pairs of blocks and calculate the average.
Attached files
shifr.b64
Log in to download
SHA-256 checksums
shifr.b64: 17a3c752db8d75e179d0605814a6764fcbaff4645bfab034c15b9f2b6bf8d6c9
To submit a flag, log in.