XOR Cipher

Encrypt and decrypt text with the XOR cipher online. The tool applies the bitwise exclusive OR operation byte-by-byte, supports text keys and hex keys, repeats short keys cyclically, and returns encrypted output as a hexadecimal string.

Key
Input
0 chars · 0 bytes
Try:
Result
✓ Symmetric cipher — same key used to encrypt and decrypt ✓ Short key cycles automatically to match message length ✓ We never store your messages ✓ Processed on our server
Examples
Encrypt HELLO Key: KEY
Input HELLO
Output 030015070A

H(72)^K(75)=03, E(69)^E(69)=00, L(76)^Y(89)=15, L(76)^K(75)=07, O(79)^E(69)=0A.

Encrypt ATTACK AT DAWN Key: SECRET
Input ATTACK AT DAWN
Output 12111713061F730417720115040B

Each letter XOR-ed with the cycling key SECRET. The space character is included in the XOR operation.

Decrypt hex ciphertext Key: KEY
Input 030015070A
Output HELLO

Paste the hex string and use the same key — XOR restores the original text.

Encrypt with hex key Key: 42 (HEX)
Input HELLO
Output 0A070E0E0D

Key format: Hex. Single-byte key 0x42: H(0x48)^0x42=0x0A, E(0x45)^0x42=0x07, L(0x4C)^0x42=0x0E, O(0x4F)^0x42=0x0D.

How the XOR cipher works

The XOR cipher is a symmetric byte-level encryption method based on the bitwise exclusive OR operation. Each byte of the input message is combined with one byte of the key. If the key is shorter than the message, the key is repeated cyclically until every byte has been processed.

XOR has a useful reversible property: applying the same key a second time restores the original data. That is why this tool can use the same algorithm for encryption and decryption. In Encrypt mode it takes normal text and returns hexadecimal ciphertext. In Decrypt mode it expects a valid hex string, converts it back to bytes, applies XOR with the same key, and returns the plaintext.

This approach is often described as gamma encryption because the key bytes act like a keystream, or gamma, that is combined with the message. The quality of that keystream determines the strength of the result.

Text keys, hex keys, and hex output

The service supports two key formats. In Text mode, the key is treated as ordinary UTF-8 text. In Hex mode, the key is interpreted as raw bytes written in hexadecimal form, so values such as DEADBEEF or DE AD BE EF can be used directly.

Encrypted output is shown in uppercase hex because XOR can produce arbitrary binary bytes, including bytes that are not printable text. Hex encoding makes the result safe to copy, store, paste into the decoder, or use in tests and examples.

When decrypting, the input must be hexadecimal ciphertext. Spaces and non-hex separators are ignored, but the remaining hex data must contain complete byte pairs.

XOR cipher, Vernam cipher, and one-time pad

The XOR cipher and the Vernam cipher use the same core operation: message bytes are combined with key bytes using XOR. The practical difference is how the key is chosen and reused.

A true one-time pad requires a random key that is at least as long as the message and never used again. Under those conditions, XOR-based encryption can provide perfect theoretical secrecy. A typical XOR cipher tool, however, uses a reusable key and repeats it when necessary. This is convenient for learning, debugging, and experimentation, but it does not provide modern cryptographic security.

When to use this XOR cipher tool

Use this online XOR encoder and decoder to study bitwise encryption, test how repeating-key XOR works, inspect hex ciphertext, or reproduce simple XOR transformations in educational materials and programming tasks.

For real protection of passwords, private messages, API tokens, or production data, use a modern authenticated encryption algorithm instead of a classical repeating-key XOR cipher.

FAQ

XOR operates on raw bytes, and the result can contain any byte value including non-printable characters and null bytes. Hexadecimal encoding provides a safe, readable representation of arbitrary binary data. When decrypting, paste the hex ciphertext: the tool converts it back to bytes, applies XOR, and returns the original text.

Both ciphers apply XOR byte-by-byte with a key. The key difference is in key management: the Vernam cipher, or one-time pad, requires a truly random key that is at least as long as the message and never reused, which makes it theoretically unbreakable. A typical XOR cipher uses a shorter repeating key for convenience, which makes it vulnerable to statistical attacks when the key is short or reused.

Because XOR is self-inverse (A XOR B XOR B = A), decryption uses the same key as encryption. Select the Decode tab, paste the hex ciphertext into the input field, enter the same key, and run the tool. It decodes the hex bytes, applies XOR, and returns the original plaintext.

The tool supports text keys and hex keys. Text keys are used as UTF-8 bytes. Hex keys are interpreted as raw byte values, so you can enter key material such as 42, DEADBEEF, or DE AD BE EF.

Yes. The tool ignores non-hex separators when reading hex data. After separators are removed, the remaining value must contain an even number of hexadecimal characters so it can be decoded into complete bytes.

The key repeats cyclically until it reaches the length of the message. This is common in repeating-key XOR, but it also creates patterns that can make the ciphertext easier to analyze.

Repeating-key XOR is useful for education and simple byte-level experiments, but it is not secure for modern data protection. Security improves only when the key material is random, at least as long as the message, and never reused, which turns the method into a one-time pad.

Yes. The tool works on bytes, so Unicode text is processed as UTF-8 data. The encrypted result is still shown as hex because the output bytes may not be printable characters.

In gamma-style encryption, the message is combined with a sequence of key bytes called a gamma or keystream. XOR is the operation that combines that keystream with the message and later reverses it with the same keystream.
Related tools

Vernam Cipher

XOR-based Vernam encryption with Base64 output.

Vigenere Cipher

Keyword-based polyalphabetic encryption and decryption.

Caesar Cipher

Classic letter-shift cipher with custom shift values.

Playfair Cipher

Classic digraph substitution cipher with keyword matrix encryption.