Rust · From scratch · RFC 8439
Cipherlock is a single binary that implements a real modern AEAD, ChaCha20-Poly1305, from scratch. Encrypt and decrypt files with a passphrase, or read the source to see exactly how authenticated encryption works.
This is a second, independent implementation of the same ChaCha20-Poly1305 construction, written in plain JavaScript and running entirely on this page. Nothing you type here leaves your browser.
encrypt then decrypt to recover the text · tamper flips one ciphertext bit
Two primitives, combined encrypt then authenticate, so a wrong passphrase or a tampered file fails loudly.
A stream cipher that expands a 256 bit key, a 96 bit nonce, and a counter into a keystream using 20 rounds of add rotate xor quarter rounds. XORed with the plaintext, it produces the ciphertext.
A one time message authenticator. A fresh key is derived from ChaCha20 for every message, and the authenticator produces a 128 bit tag over the ciphertext and any associated data.
The two are combined into AEAD_CHACHA20_POLY1305, encrypt then authenticate. Decryption verifies the tag before releasing any plaintext.
The same construction you just tried above, encrypting a real file on disk.
cargo build --release
cipherlock encrypt secret.txt secret.txt.lock --pass "correct horse battery staple"
cipherlock decrypt secret.txt.lock secret.txt --pass "correct horse battery staple"
cargo test, alongside an encrypt then decrypt roundtrip test and a tamper detection test that flips a ciphertext byte and confirms decryption fails. This is a correct, teaching grade tool. It is not a substitute for an audited cryptography library in production.