ROT13
ROT13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the Latin alphabet. ROT13 is a special case of the Caesar cipher which was developed in ancient Rome, used by Julius Caesar in the 1st century BC.[1] An early entry on the Timeline of cryptography. ROT13 can be referred by "Rotate13", "rotate by 13 places", hyphenated "ROT-13" or sometimes by its autonym "EBG13". DescriptionApplying ROT13 to a piece of text requires examining its alphabetic characters and replacing each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary.[2] To encode message: A becomes N, B becomes O, and so on up to M, which becomes Z, then the sequence continues at the beginning of the alphabet: N becomes A, O becomes B, and so on to Z, which becomes M. To decode a message, You apply the same substitution rules, but this time on the ROT13 encrypted text. (Any other character, for example numbers, symbols, punctuation or whitespace, are left unchanged.) Because there are 26 letters in the Latin alphabet and 26 = 2 × 13, the ROT13 function is its own inverse:[2]
In other words, two successive applications of ROT13 restore the original text (in mathematics, this is sometimes called an involution; in cryptography, a reciprocal cipher). The transformation can be done using a lookup table, such as the following:
For example, in the following joke, the punchline has been obscured by ROT13:
Transforming the entire text via ROT13 form, the answer to the joke is revealed:
A second application of ROT13 would restore the original. UsageROT13 is not intended to be used in modern times. At the time of conception in an era of Ancient Roman technology, the encryption scheme was not represented by a mathematical structure. The key to decrypt a message requires no more knowledge than the fact that ROT13 is in use. Even if secrecy does not fail, any alien party or individual, capable of intercepting the message, could break the code by spending enough time on decoding the text through frequency analysis[2] or finding other patterns. In the early 80's, ROT13 was supposedly used on Usenet newsgroup servers[3] This in an effort to hide potentially offensive jokes, or to obscure an answer to a puzzle or other spoiler [unreliable source?] , or to fool less sophisticated spam bots[dubious – discuss]. ROT13 has been the subject of many jokes. The 1989 International Obfuscated C Code Contest (IOCCC) included an entry by Brian Westley. Westley's computer program can be encoded in ROT13 or reversed and still compiles correctly. Its operation, when executed, is either to perform ROT13 encoding on, or to reverse its input.[4] In December 1999, it was found that Netscape Communicator used ROT13 as part of an insecure scheme to store email passwords.[5] In 2001, Russian programmer Dimitry Sklyarov demonstrated that an eBook vendor, New Paradigm Research Group (NPRG), used ROT13 to encrypt their documents. It has been speculated that NPRG may have mistaken the ROT13 toy example—provided with the Adobe eBook software development kit—for a serious encryption scheme.[6] Windows XP uses ROT13 on some of its registry keys.[7] ROT13 is also used in the Unix fortune program to conceal potentially offensive dicta. Johann Ernst Elias Bessler, an 18th-century clock maker and constructor of perpetual motion machines, pointed out that ROT13 encodes his surname as Orffyre. He used its latinised form, Orffyreus, as his pseudonym.[8] Net cultureBecause of its utter unsuitability for real secrecy, ROT13 has become a catchphrase to refer to any conspicuously weak encryption scheme; a critic might claim that "56-bit DES is little better than ROT13 these days". In a play on real terms like "double DES" several terms cropped up with humorous intent:
ROT13 jokes were popular on many newsgroup servers, like net.jokes as early as the 1980s.[3] The newsgroup alt.folklore.urban coined a word—furrfu—that was the ROT13 encoding of the frequently encoded utterance "sheesh". "Furrfu" evolved in mid-1992 as a response to postings repeating urban myths on alt.folklore.urban, after some posters complained that "Sheesh!" as a response to newcomers was being overused.[10] Using a search engine on public social networks, yields results for ROT13 in jokes to this day. Letter games
ROT13 provides an opportunity for letter games. Some words will, when transformed with ROT13, produce another word. Examples of 7-letter pairs in the English language are abjurer and nowhere, and Chechen and purpura. Other examples of words like these are shown in the table.[11] The pair gnat and tang is an example of words that are both ROT13 reciprocals and reversals. Variants and combinationsROT5 is a practice similar to ROT13 that applies to numeric digits (0 to 9). ROT13 and ROT5 can be used together in the same message, sometimes called ROT18 (18 = 13 + 5) or ROT13.5. ROT47 is a derivative of ROT13 which, in addition to scrambling the basic letters, treats numbers and common symbols. Instead of using the sequence A–Z as the alphabet, ROT47 uses a larger set of characters from the common character encoding known as ASCII. Specifically, the 7-bit printable characters, excluding space, from decimal 33 '!' through 126 '~', 94 in total, taken in the order of the numerical values of their ASCII codes, are rotated by 47 positions, without special consideration of case. For example, the character A is mapped to p, while a is mapped to 2. The use of a larger alphabet produces a more thorough obfuscation than that of ROT13; for example, a telephone number such as +1-415-839-6885 is not obvious at first sight from the scrambled result Z'\c`d\gbh\eggd. On the other hand, because ROT47 introduces numbers and symbols into the mix without discrimination, it is more immediately obvious that the text has been encoded. Example:
enciphers to
The GNU C library, a set of standard routines available for use in computer programming, contains a function—memfrob()[12]—which has a similar purpose to ROT13, although it is intended for use with arbitrary binary data. The function operates by combining each byte with the binary pattern 00101010 (42) using the exclusive or (XOR) operation. This effects a simple XOR cipher. Like ROT13, XOR (and therefore memfrob()) is self-reciprocal, and provides a similar, virtually absent, level of security. ImplementationtrThe ROT13 and ROT47 are fairly easy to implement using the Unix terminal application tr; to encrypt the string "Pack My Box With Five Dozen Liquor Jugs" in ROT13: $ # Map upper case A-Z to N-ZA-M and lower case a-z to n-za-m
$ tr 'A-Za-z' 'N-ZA-Mn-za-m' <<< "Pack My Box With Five Dozen Liquor Jugs"
Cnpx Zl Obk Jvgu Svir Qbmra Yvdhbe Whtf
and the string "The Quick Brown Fox Jumps Over The Lazy Dog" for ROT47: $ echo "The Quick Brown Fox Jumps Over The Lazy Dog" | tr '\!-~' 'P-~\!-O'
%96 "F:4< qC@H? u@I yF>AD ~G6C %96 {2KJ s@8
Emacs and VimIn Emacs, one can ROT13 the buffer or a selection with the commands[13] In the Vim text editor, one can ROT13 a buffer with the command[14] PythonThe module codecs provides 'rot13' text transform.[15] >>> import codecs
>>> print(codecs.encode('The Quick Brown Fox Jumps Over The Lazy Dog', 'rot13'))
Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt
Without importing any libraries, it can be done in a two-line list comprehension: string = "Quartz glyph job vext cwm porshrop finks?!"
for abcd in ["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]:
string = ''.join([abcd[(abcd.index(char) + 13) % 26] if char in abcd else char for char in string])
print(string)
# Dhnegm tylcu wbo irkg pjz cbefuebc svaxf?!
For Python 3, you can use the method str.maketrans() text = "this is an example without capital letters"
my_rot13 = str.maketrans(
"abcdefghijklmnopqrstuvwxyz", "nopqrstuvwxyzabcdefghijklm"
)
print(text.translate(my_rot13))
# guvf vf na rknzcyr jvgubhg pncvgny yrggref
See alsoReferences
External links
|