text.ciphers
Caesar, ROT13, Atbash, Vigenère, Morse, Braille, NATO spelling
Example results generated on 2026-10-08. Ones using
now,todayor randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.
Functions
| function | description |
|---|---|
caesar(s: str, shift: int) | shift each letter by shift places; negative shifts decode |
rot13(s: str) | Caesar by 13; applying it twice gives the original |
atbash(s: str) | mirror the alphabet: a <-> z, b <-> y |
vigenere(s: str, key: str) | Caesar with a shift per letter from a key word |
unvigenere(s: str, key: str) | undo vigenere |
morse(s: str) | text to Morse code, or Morse (dots, dashes, / between words) back to text |
braille(s: str) | text to Grade 1 Braille cells, or Braille back to text |
nato(s: str) | spell with the NATO phonetic alphabet |
caesar
caesar(s: str, shift: int): shift each letter by shift places; negative shifts decode
"hello".caesar(3)
# → "khoor"
"khoor".caesar(-3)
# → "hello"
rot13
rot13(s: str): Caesar by 13; applying it twice gives the original
"hello".rot13
# → "uryyb"
See also: caesar
atbash
atbash(s: str): mirror the alphabet: a <-> z, b <-> y
"wizard".atbash
# → "draziw"
See also: caesar
vigenere
vigenere(s: str, key: str): Caesar with a shift per letter from a key word
"attack at dawn".vigenere("lemon")
# → "lxfopv ef rnhr"
See also: unvigenere, caesar
unvigenere
unvigenere(s: str, key: str): undo vigenere
"lxfopv ef rnhr".unvigenere("lemon")
# → "attack at dawn"
See also: vigenere
morse
morse(s: str): text to Morse code, or Morse (dots, dashes, / between words) back to text
"sos".morse
# → "... --- ..."
".... .. / - .... . .-. .".morse
# → "HI THERE"
See also: braille
braille
braille(s: str): text to Grade 1 Braille cells, or Braille back to text
"hello world".braille
# → "⠓⠑⠇⠇⠕⠀⠺⠕⠗⠇⠙"
"⠓⠊".braille
# → "hi"
nato
nato(s: str): spell with the NATO phonetic alphabet
"SOS".nato
# → "Sierra Oscar Sierra"
"b2b".nato
# → "Bravo Two Bravo"
See also: morse
More examples
ciphers
# SOS
"sos".morse
# → "... --- ..."
# and back
"... --- ...".morse
# → "SOS"
# spoilers
"the butler did it".rot13
# → "gur ohgyre qvq vg"
# crack a Caesar
(1..26).map(|k| "Wkh hdjoh odqgv".caesar(-k)).grep("eagle")
# → ["The eagle lands"]
# Vigenère round trip
"attack at dawn".vigenere("lemon").unvigenere("lemon")
# → "attack at dawn"
# Braille
"hello".braille
# → "⠓⠑⠇⠇⠕"
# spell it over the phone
"zil 2".nato
# → "Zulu India Lima / Two"