XOR Cipher Tool
NewEncrypt text with a repeating-key XOR cipher and view the result as hex or Base64, with matching decryption back to plain text.
—
XOR encryption repeats the key byte-by-byte across the input and combines each pair with a bitwise XOR. It's symmetric — applying the exact same key to the output reverses it back to the original — but a repeating short key over UTF-8 text is not secure for real secrets; it's shown here for learning, CTF-style puzzles, and simple obfuscation, not for protecting sensitive data.
Frequently Asked Questions
How does repeating-key XOR encryption work?
Each byte of the input text is combined with a byte from the key using a bitwise XOR operation; if the key is shorter than the text (which it usually is), the key simply repeats from the beginning for as many bytes as needed.
Why does encrypting the same text twice with the same key give back the original?
XOR is its own inverse at the bit level: `a XOR b XOR b` always equals `a` — so applying the identical key a second time undoes the first operation exactly, which is also exactly how the "Decrypt" mode works here (it runs the same XOR operation, just against encoded input instead of plain text).
Why choose between hex and Base64 output?
XOR operates on raw bytes, and raw bytes often aren't printable/copyable as plain text — hex represents each byte as two readable characters (easier to read and debug byte-by-byte), while Base64 is more compact and is the more common format for embedding binary data in JSON, URLs, or config files.
Is XOR cipher secure for real encryption?
Not with a short, reused key — a repeating XOR key is vulnerable to frequency analysis and known-plaintext attacks (this is the same weakness that broke many historical ciphers); true one-time-pad security only holds if the key is truly random, at least as long as the message, and never reused, which isn't practical for everyday use. This tool is for learning, CTF challenges, and simple obfuscation, not securing real secrets.
Does the key length need to match the text length?
No — the key repeats automatically to cover however long the input is, so a short, memorable key like "secret" works fine against text of any length.