Byte XOR with a single-use pad
One-Time Pad Encryptor and Decryptor
Encrypt UTF-8 text with an equal-length byte pad, or decrypt strictly encoded ciphertext with the same pad.
Security boundary: this tool enforces equal byte length only. A real one-time pad also needs independent uniform randomness, secret delivery, and permanent single use, none of which a web page can verify.
01 / Workspace
Encrypt or decrypt bytes
Encrypt converts text to UTF-8 bytes, then XORs each byte with one pad byte.
The selected format applies to both the pad and ciphertext. Decoding requires canonical text with no whitespace.
All Unicode text is encoded as UTF-8. Browser text fields normalize CR and CRLF line endings to LF.
Hex accepts an even number of ASCII hex digits with no prefix or separators. Pad bytes must exactly match the plaintext byte length.
Generated pad note: generation uses crypto.getRandomValues only after you press the button. Web Crypto specifies a cryptographically strong pseudorandom source, not a proof of information-theoretic randomness.
Keyboard shortcut: Ctrl+Enter or Command+Enter runs the selected mode.
Ready to encrypt.
02 / Result
Result
Ciphertext is canonical uppercase hex with no spaces. Keep it separate from the secret pad.
03 / Exact convention
What this tool does
- Encode text as UTF-8. Pad length is measured in bytes, not visible characters or JavaScript string units. An emoji usually needs four pad bytes.
- Require an exact pad. A shorter pad is never repeated and a longer pad is never truncated. Every plaintext or ciphertext byte must have exactly one pad byte.
- XOR byte by byte. Encryption calculates
ciphertext = plaintext XOR pad. Decryption applies the same XOR operation again. - Decode strictly. Hex and padded Base64 follow canonical RFC 4648 forms with no spaces or line breaks. Decrypted bytes must be well-formed UTF-8; replacement characters are never inserted.
- Fail without partial output. The tool validates encoded text, byte limits, equal lengths, and final UTF-8 before displaying any result.
Known XOR vector
- Plaintext
ABC, UTF-8 bytes41 42 43- Hex pad
010203- Hex ciphertext
404040- Base64 forms
- Pad
AQID, ciphertextQEBA
Decrypting either encoded ciphertext with its matching pad returns ABC.
Security and operational limits
- A true one-time pad needs independent, uniformly random secret bytes equal in length to the message, securely delivered in advance and never reused for any other data.
- This page can enforce equal byte length. It cannot prove pad randomness, stop reuse, protect pad delivery, or know whether another copy of a pad exists.
- Browser-generated bytes come from a cryptographically strong pseudorandom generator. The Web Crypto specification does not guarantee a minimum amount of information-theoretic entropy.
- XOR provides no authentication or tamper detection. A modified ciphertext changes decrypted bytes, and a wrong pad can sometimes produce plausible UTF-8 text without an error.
- For ordinary applications, use a reviewed authenticated-encryption system with sound key management. This educational utility does not implement a modern encryption protocol.
- Input and decoded byte work is limited to 65,536 bytes. Hex is uppercase on output; Base64 uses the standard alphabet and required padding.
- Clear empties the fields but cannot guarantee secure erasure from browser memory, device memory, the clipboard, screenshots, or backups.