Blog Archives

How to encrypt a string with ROT13 (one liner)

ROT13 is a variation of the caesar chiffre. It replaces each letter with the letter 13 positions after that letter. A nice side effect: you need only a function to encrypt a string. If you encrypt an encrypted string, you’ll get the plaintext.

Encryption:
echo 'This is a Test' | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Output: Guvf vf n Grfg

Decryption:
echo 'Guvf vf n Grfg' | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Output: This is a Test