XOR Encrypt & Decrypt Online | Cipher Browser Brute Force Auto-Solve
Encryption How It Works
What Is XOR Cipher?
XOR (exclusive OR) is the smallest possible cipher: every byte of the message is combined with a key byte using the XOR operation. It is the building block that real ciphers are made of — ChaCha20 and AES-CTR are, at their core, XOR against a cryptographically secure keystream. This tool lets you work with the raw operation directly, and everything runs locally in your browser.
Encrypt and decrypt are the same operation: XOR is its own inverse (a ⊕ b ⊕ b = a) — applying the key to the ciphertext returns the plaintext. The key bytes repeat over the input; enter it as text or hex, or click Random for a 16-byte key. Encrypt takes UTF-8 text and produces Base64 or Hex; decrypt reverses the process. When decryption produces invalid UTF-8, the result is shown as hex automatically.
When to Use XOR Cipher
- Educational purposes — Understanding the fundamentals of symmetric encryption and stream ciphers
- CTF challenges — Capture-the-flag competitions often feature XOR-based puzzles
- Obfuscation — Simple data obfuscation (not encryption) for non-security-critical applications
- One-time pad — The only theoretically unbreakable cipher, but requires a truly random key as long as the message
- Building block for learning — Understanding how modern ciphers (ChaCha20, AES-CTR) use XOR internally
- When NOT to use — For any real encryption needs, use AES-256-GCM or ChaCha20-Poly1305 instead
Attack Methods Reference
| Method | Key Type | Input Needed | Speed |
|---|---|---|---|
| Brute Force | Single byte (0-255) | Ciphertext only | Instant (256 tries) |
| Auto-solve | Multi-byte repeating | Ciphertext only | Fast (statistical) |
| Key Recovery | Any length | Ciphertext + known plaintext | Instant (direct XOR) |
Standards Compliance
- XOR Operation — Fundamental bitwise operation in computer science
- One-Time Pad — Information-theoretically secure when used correctly (Shannon, 1949)
- Stream Ciphers — Modern ciphers (ChaCha20, AES-CTR) use XOR with cryptographically secure keystreams
- NIST — XOR alone is not standardized for encryption; use AES or approved stream ciphers
Last updated:
Code Examples
XOR encrypt/decrypt in multiple languages:
JavaScript — Browser (Repeating Key)
// XOR with repeating key
function xor(input, key) {
const out = new Uint8Array(input.length);
for (let i = 0; i < input.length; i++) {
out[i] = input[i] ^ key[i % key.length];
}
return out;
}
const text = new TextEncoder().encode('secret message');
const key = new TextEncoder().encode('key');
const ciphertext = xor(text, key);
console.log('Ciphertext (Base64):', btoa(String.fromCharCode(...ciphertext)));
// Decrypt (same operation)
const decrypted = xor(ciphertext, key);
console.log('Decrypted:', new TextDecoder().decode(decrypted)); Python — XOR with Repeating Key
def xor(data: bytes, key: bytes) -> bytes:
return bytes(b ^ key[i % len(key)] for i, b in enumerate(data))
plaintext = b'secret message'
key = b'key'
ciphertext = xor(plaintext, key)
print(f'Ciphertext (hex): {ciphertext.hex()}')
# Decrypt (same operation)
decrypted = xor(ciphertext, key)
print(f'Decrypted: {decrypted.decode()}') Go — XOR Cipher
package main
import (
"encoding/hex"
"fmt"
)
func xor(data []byte, key []byte) []byte {
result := make([]byte, len(data))
for i, b := range data {
result[i] = b ^ key[i%len(key)]
}
return result
}
func main() {
plaintext := []byte("secret message")
key := []byte("key")
ciphertext := xor(plaintext, key)
fmt.Printf("Ciphertext (hex): %s\n", hex.EncodeToString(ciphertext))
// Decrypt (same operation)
decrypted := xor(ciphertext, key)
fmt.Printf("Decrypted: %s\n", decrypted)
} Rust — XOR Encryption
fn xor(data: &[u8], key: &[u8]) -> Vec<u8> {
data.iter()
.enumerate()
.map(|(i, &b)| b ^ key[i % key.len()])
.collect()
}
fn main() {
let plaintext = b"secret message";
let key = b"key";
let ciphertext = xor(plaintext, key);
println!("Ciphertext (hex): {:?}", ciphertext.iter().map(|b| format!("{:02x}", b)).collect::<Vec<_>>().join(""));
// Decrypt (same operation)
let decrypted = xor(&ciphertext, key);
println!("Decrypted: {}", String::from_utf8(decrypted).unwrap());
} Node.js — XOR with Buffer
function xor(data, key) {
const result = Buffer.alloc(data.length);
for (let i = 0; i < data.length; i++) {
result[i] = data[i] ^ key[i % key.length];
}
return result;
}
const plaintext = Buffer.from('secret message', 'utf8');
const key = Buffer.from('key', 'utf8');
const ciphertext = xor(plaintext, key);
console.log('Ciphertext (hex):', ciphertext.toString('hex'));
// Decrypt (same operation)
const decrypted = xor(ciphertext, key);
console.log('Decrypted:', decrypted.toString('utf8')); Common Pitfalls & Attack Vectors
Security Notes
Disclaimer
Disclaimer: This page is for educational and CTF purposes only. It does not constitute professional security advice. XOR encryption is NOT secure for real-world use. For production encryption, use AES-256-GCM or ChaCha20-Poly1305 and consult official standards (NIST, IETF).
Further Reading & Standards
- One-Time Pad — Wikipedia: One-Time Pad
- XOR Cipher — Wikipedia: XOR Cipher
- Stream Ciphers — Understanding Modern Stream Ciphers
- Claude Shannon's Work — Communication Theory of Secrecy Systems (1949)
Related Concepts
- Symmetric vs Asymmetric Encryption — Understanding the difference between shared-key and public-key cryptography
- AES Encryption — The NIST-standard block cipher that uses XOR internally
- Key Management — Best practices for generating and protecting encryption keys
- Post-Quantum Cryptography — Future-proofing your encryption against quantum attacks
Related Tools
Need real encryption? Try AES Encrypt/Decrypt for NIST-standard security or ChaCha20 Encrypt/Decrypt for a modern stream cipher. For generating strong keys, the Password Generator creates cryptographically secure random strings.
Frequently Asked Questions
Is XOR encryption secure?
Only under one exact condition: the key must be truly random, at least as long as the message, and used exactly once (a one-time pad). XOR with a short repeating key is not secure and can be broken in seconds. Use XOR for learning and CTF puzzles; use AES or ChaCha20 for real security.
How does the brute-force panel work?
For single-byte keys, the tool tries all 256 possible key values and shows each decryption result. Look for readable text in the output — the correct key produces intelligible plaintext. This works instantly in your browser.
What does Auto-solve do?
Auto-solve uses statistical analysis (index of coincidence + frequency analysis) to crack multi-byte repeating-key XOR automatically. It finds the key length first, then solves each key position. No key input needed — just paste the ciphertext.
What input formats are supported?
Encrypt takes plain text (UTF-8) and produces Base64 or Hex output. Decrypt takes Base64 or Hex ciphertext and returns plain text. The key can be entered as text or hex in both modes. If decryption produces invalid UTF-8 (wrong key), the result is shown as hex automatically.
How do I break a repeating-key XOR?
For single-byte keys, brute force all 256 possibilities and look for readable text — this tool automates it in the Single-byte brute force panel. For multi-byte repeating keys, statistical methods (index of coincidence, then per-position frequency analysis) crack it: find the key length first, then solve each key position. The Auto-solve panel does this end-to-end; if you already know a plaintext fragment, the Key recovery panel gets the key directly (key = ciphertext XOR plaintext).
Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.
More in Encryption
AES Encrypt/Decrypt
Encrypt and decrypt with AES-128/192/256 online. GCM, CTR, and OpenSSL-compatible CBC modes. Passphrase or raw key, custom IV.
ChaCha20 / Salsa20 Encrypt/Decrypt
Encrypt and decrypt with ChaCha20, XChaCha20, ChaCha20-Poly1305 (AEAD), or Salsa20 online. Passphrase mode with PBKDF2 key derivation.
RSA Encrypt / Decrypt
Encrypt and decrypt with RSA-OAEP online via Web Crypto API. Built-in key generator, PKCS#8/PKCS#1 conversion, SHA-256/384/512.
DES Encrypt/Decrypt
Encrypt and decrypt with DES or 3DES (Triple DES) online. CBC/ECB/CFB/OFB modes, PKCS7/NoPadding, OpenSSL compatible.
JWE Encrypt / Decrypt
Encrypt and decrypt JWE (JSON Web Encryption) tokens online. RSA-OAEP, AES key wrap, PBES2 password-based key management, A128GCM/A256GCM.
Blowfish Encrypt/Decrypt
Encrypt and decrypt with Blowfish online. 5 cipher modes, 5 paddings, GBK/UTF-16 support, OpenSSL passphrase compatible.
PGP Encrypt / Decrypt
Encrypt, decrypt, sign, and verify with OpenPGP online. Public key and password modes, built-in key generator, GnuPG compatible.