ROT13

February 20, 2009

rot13 /rot ther’teen/ /n.,v./ [Usenet: from `rotate alphabet 13 places’] The simple Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet, so that “The butler did it!” becomes “Gur ohgyre qvq vg!” Most Usenet news reading and posting programs include a rot13 feature. It is used to enclose the text in a sealed wrapper that the reader must choose to open — e.g., for posting things that might offend some readers, or spoilers. A major advantage of rot13 over rot(N) for other N is that it is self-inverse, so the same code can be used for encoding and decoding.

Write a function that takes a string and returns the ROT13 version of the string; you may assume that the character set is ascii. What is the meaning of “Cebtenzzvat Cenkvf vf sha!”

Like this:

LikeLoading...

Related

35 Responses to “ROT13”

This is a rather trivial exercise for Oracle’s PL/SQL since it has a TRANSLATE function. This function translates each character in a given string using “from” and “to” positional strings, passed as parameters (along with the target string, of course). Each character in the target string found in the “from” string is replaced by the corresponding character in the “to” string. Quite handy, especially for doing ROT13. But as you can see, I only included a couple of special characters in the translation strings, so my first implementation was rather limited:

Reblogged this on graveborn and commented:
The following is the source code to my solution to the 6th problem – “ROT13: A simple Caesar-shift cipher” – of Programming Praxis, and my first program for the Amstrad Plus.

I don’t know if the additional features of the Amstrad Plus are accessible through CP/M and Pascal, but my goal when programming the following solution was merely to gain a little familiarity with using the Amstrad Plus, eg. a familiarity with editing, saving, and loading text files, and erasing files.