One-Time Pad

Suppose that the letters (and some characters) are converted to binary as follows.

char abc def gh
number 000000000100010 000110010000101 0011000111
char i jkl mno p
number 01000 010010101001011 011000110101110 01111
char qr stu vwx
number 1000010001 100101001110100 101011011010111
char yz. ,() ?@
number 110001100111010 110111110011101 1111011111

Then the plaintext message

      heilhitler

becomes the plaintext bit string

      00111,00100,01000,01011,00111,01000,10011,01011,00100,10001

Suppose we generate the random bitstring

      10100,11000,10111,10000,00010,11101,11001,11010,10111,11011

and XOR the corresponding bits of this random string with the message above. The result is

      10011,11100,11111,11011,00101,10101,01010,10001,10011,01010

which corresponds to the message

      t(@,fvkrtk

Anyone who has the random bit string can recover the message, while anyone who does not have the random bit string has no information about the text. Unlike any other cryptosystem, the one-time pad offers provable (or perfect) security, provided that the key is only used once.

However, if we want to get the sender in trouble with his friends, we could claim that the secret random bit string was instead

      10100,11100,10010,11101,00010,11101,11001,11010,10111,11011

in which case the message would "decrypt" as

      hanghitler