in reply to How secure is XOR encryption?
Distilled from the Cryptography FAQ:
8.2. How do I break a Vigenere (repeated-key) cipher?XOR "encryption" is a toy. Play with it, have fun. Don't treat it as something real.
A repeated-key cipher, where the ciphertext is something like the plaintext xor KEYKEYKEYKEY (and so on), is called a Vigenere cipher.
If the key is not too long and the plaintext is in English, do the following:
- Discover the length of the key by counting coincidences. (See Gaines [GAI44], Sinkov [SIN66].) Trying each displacement of the ciphertext against itself, count those bytes which are equal.
If the two ciphertext portions have used the same key, something over 6% of the bytes will be equal. If they have used different keys, then less than 0.4% will be equal (assuming random 8-bit bytes of key covering normal ASCII text). The smallest displacement which indicates an equal key is the length of the repeated key.
- Shift the text by that length and XOR it with itself. This removes the key and leaves you with text XORed with itself. Since English has about 1 bit of real information per byte, 2 streams of text XORed together has 2 bits of info per 8-bit byte, providing plenty of redundancy for choosing a unique decryption. (And in fact one stream of text XORed with itself has just 1 bit per byte.)
If the key is short, it might be even easier to treat this as a standard polyalphabetic substitution. All the old cryptanalysis texts show how to break those. It's possible with those methods, in the hands of an expert, if there's only ten times as much text as key. See, for example, Gaines [GAI44], Sinkov [SIN66].
Brainbench 'Most Valuable Professional' for Perl
|Replies are listed 'Best First'.|
Re: Re: How secure is XOR encryption? (Russ: not at ALL)
by Anonymous Monk on May 03, 2004 at 16:26 UTC
by Russ (Deacon) on May 03, 2004 at 22:51 UTC
|A reply falls below the community's threshold of quality. You may see it by logging in.|