Ciphers are the encoding algorithms used to encode and decode the data. It converts the plaintext to ciphertext using a key that determines how it's done. The first cipher device was used by Spartans as early as 400 bc for secret communication among their military officials.
ROT13 (rotate by 13 places, sometimes referred to as ROT-13) is a substitution cipher with a shift of 13. That technique substitutes a letter with the 13th letter after it in the alphabet.
Encryption with Rot13 substitutes a letter with the 13th letter after it in the English alphabet. The 13th position in the alphabet shifts each letter. For example, A becomes N, B becomes O, and so on up to M, which becomes Z. The sequence continues as N becomes A, O becomes B, and so on up to Z, which becomes M.
Thus, in ROT13, every letter is shifted to the 13th letter after it to encrypt or decrypt the text.
Note: Only those alphabets that are in English are get affected. Numbers, symbols, whitespace, and all other characters remain unaffected.
ROT13 decryption is just like ROT13 encryption because of the reciprocal substituting alphabet. Write from A to M on a piece of paper, and below that, write from N to Z. You can then replace the letters accordingly.
For example ABCDEFGHIJKLM becomes NOPQRSTUVWXYZ
Here, A becomes N and goes to M, which becomes Z. The pattern continues as N becomes the A, and so on to Z, which becomes M.
In the early 1980s, the ROT13 was used in a net.jokes newsgroup. Currently, it's used to hide offensive jokes, puzzle solutions, movies, other story spoilers, and abusive material from readers that find it offensive.
For example, in the following joke, the punchline is hidden using ROT13.
Joke: How can you tell an extrovert from an introvert at NSA?
Punchline: Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf.
If we use the ROT13 application for decoding, then the punchline will be
In the elevators, the extrovert looks at the OTHER guy's shoes.
Generally, the ROT13 is preferred over others because 13 is the value for which the encoding and decoding are equivalent. In the English alphabet, there are 26 characters (13x2). Therefore, ROT13 is its inverse. The same function that encrypts the text will also decrypt the text.
ROT13 uses the exact mechanism as Caesar cipher. However, it substitutes a letter with the 13th letter after it in the alphabet. Therefore, two rotations will bring you back to your original text.
In English, there is a total of 26 alphabets. Thus, there are 25 possible keys, each possible shift of alphabet. That means we can shift from ABC to Z along 25 times.
From a security perspective, the ROT13 cipher is not secure. It's just a particular form of Ceaser cipher. One can easily break it down by frequency analysis or just trying out all 25 keys. You can break down the ROT13 by replacing a letter with the 13th letter after it in the English alphabet. Therefore, it has no practical use. In simple words, two successive conversions of ROT13 restore the original text. It's a canonical example of weak encryption.