RU EN ES 中文

Vernam Cipher

XOR encryption · Bitwise operation

How does the Vernam cipher work?

+

The Vernam cipher (one-time pad) is an encryption method that is theoretically unbreakable under three conditions: the key is random, equal in length to the message, and used only once.

1 Choosing an encoding

Message characters are converted into bits. Available encodings: Baudot code (5 bits/char), ASCII 7/8 bit, UTF-8 (variable length). The character table updates dynamically.

2 Entering the message

The text is converted into a bit sequence according to the selected encoding. Unsupported characters are highlighted with a warning.

3 Key generation

The key is generated randomly (0/1 with equal probability). Length options: 64–2048 bits or "Match message length" (a true one-time pad). If the key is shorter than the message, it repeats cyclically (reducing security).

4 Encryption (XOR)

Each message bit is combined with a key bit using exclusive OR (XOR): 0⊕0=0, 0⊕1=1, 1⊕0=1, 1⊕1=0. Modes: step-by-step (visualizing the bitwise operation) or instant.

5 Transmission
Alice sends Bob:
  • The key — over a secure channel (animation: gold packet on a curved path)
  • The ciphertext — over an open channel (animation: blue packet on a straight path)
Both packets are displayed in HEX format (bits grouped by 8, converted into hexadecimal symbols). Arrival is synchronized.
6 Decryption

Bob applies the same key to the ciphertext using XOR: ciphertext ⊕ key = original message. Thanks to XOR's reversibility, this operation is identical to encryption.

7 Reverse encoding

The decrypted bits are converted back into characters. The user chooses a decoding encoding — the system checks the result against the original message and shows a preview.

8 Result

Final comparison: original message, key (HEX), ciphertext (HEX), decrypted text. On a successful match, a confirmation and statistics are shown.

Visualization legend:
● Message / result  |  ● Key  |  ● Ciphertext  |  ⊕ XOR operation

Important: In real cryptography the key must be truly random, never reused, and transmitted over a secure channel. This demo is an educational model.

Choose an encoding

The encoding determines how characters are converted into bits

Baudot code5 bits
Historical telegraph code (ITA1/ITA2).
A = 11000, B = 10011
ASCII 77 bits
Standard ASCII (0-127).
A = 1000001, Space = 0100000
ASCII 88 bits
Extended ASCII (0-255).
A = 01000001, Ä = 11000100
UTF-88-32 bits
Variable-length Unicode.
A = 01000001, Ж = 1101000010010110
Selected encoding
CharCodeBits