For those of you too lazy to figure out what trak3r wrote, here is that writeup after going through ROT13:

ROT13 is a super lame encryption technique that consists of shifting each letter of the alphabet thirteen places. (uvag: guvf nccneragyl-tneoyrq fragrapr vf EBG13 rapbqrq)

For those people who don't have access to tr but have access to perl and the command line, here is a short little Perl program:

while(<>) {                   #for each line of data ...
    tr/a-zA-Z/n-za-mN-ZA-M/;  #... perform ROT-13 ...
    print;                    #... and display the translated line

dafydd, being a real Perl programmer, determined how to make the program a one-liner:

    tr/a-zA-Z/n-za-mN-ZA-M/ and print while <>

If you can't even do that, but have access to the site Everything 2 (probably a safe bet), JayBonci wrote E2 Rot13 Encoder, which lets E2 do all the work..

Just because I had most of this from my Caesar shift cipher node.

Plain    a b c d e f g h i j k l m n o p q r s t u v w x y z
ROT13    N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
Or this might be simpler:
a b c d e f g h i j k l m
| | | | | | | | | | | | |
n o p q r s t u v w x y z
Here are two ways to solve your ROT-13 needs.
Use the following bookmarklet:

javascript:P9 = prompt( 'Text...', '' );

if ( P9 ) {
    S2b = '';

    for ( J7 = 0; J7 < P9.length; J7++ ) {
        C6 = P9.charCodeAt( J7 );

        if ( Math.abs( 16 - Math.abs( C6 - 93.5 ) ) <= 13 ) {
            W8b = ( C6 < 91 ) ? 65 : 97;
            S2b += String.fromCharCode(((C6 - W8b + 13) % 26 ) + W8b);
        } else {
            S2b += P9.charAt( J7 );

    alert( S2b );
} else {
    void ( null );

or use the magical perl y/a-zA-Z/n-za-mN-ZA-M/

Just another interesting fact is that the longest English words that form another word when put through rot13 are 'abjurer' and 'nowhere'.

/*  Rot-13 encoder/decoder in C
 *  This wretched little monstrosity is in the public domain.
 *  A much better solution is to use sed or tr. If you're on 
 *  Windows, go to the GNUish Project and download sed.
 *  As with any simple character translation thing, a 
 *  lookup table would be more efficient, but... come on!
 *  wharfinger  11/5/00

#include <stdio.h>
#include <ctype.h>

int r13( int c );

int main()
    int c;

    while ( ( c = getchar() ) != EOF )
        putchar( r13( c ) );

    return 0;

int r13( int c )
    /*  Okay, it's a nested ternary. I know.
        This should probably be a macro, but macros this complex 
        get on my nerves.  
        'm' is the thirteenth letter of the alphabet.
        I mean, like, in case you didn't know or something.
    return ( isalpha( c ) )
                ? ( ( tolower( c ) > 'm' ) ? ( c - 13 ) : ( c + 13 ) )
                : c;

ROT-13 is a simple way of encrypting a document. Encryption is the process if taking a document, translating it so that in its encrypted form it is not readable, but can be decrypted so that it returns back to its original readable form.

ROT-13 is the US government's idea of personal encryption. Some powerful members of government wish that this was the only form of encryption available to its citizens. Fortunately, others have more realistic views.

Encrypting and decrypting ROT-13 is easy. It is short for "Rotate 13 letters". If you know the alphabet (US centric, sorry, I realize) then you can easily make a ROT-13 chart:


Now say you want to decrypt the phrase "Uryyb jbeyq!". Take the first letter, 'U'. It's on the second row of the handy chart, and it's the 22nd letter of the alphabet. The letter right above 'U' is 'H', which is the 8th letter of the alphabet. 22 - 8 = 13, so turn the 'U' into an 'H' and move on to the next letter.

'r' coresponds with 'e' in the chart, and to doublecheck, 'r' is the 18th letter, and 'e' is the 5th, and 18 - 5 = 13. This is a good way to scramble a message so that it takes longer to read, but it's not exactly cryptography.

root mode = R = rotary debugger

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. See also spoiler space, which has partly displaced rot13 since non-Unix-based newsreaders became common.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

Update 2/26/02: DelFick /msg'ed me with his version that works for IE and Mozilla (confirmed). Cross browser capability automatically makes it better than mine and daglo's. Here's an easy-to-copy-&-paste version:
javascript: if(document.all)sel=document.selection.createRange().text; else{sel=getSelection().toString(); }if(!sel)sel=prompt('Enter the text to ROT13',''); alpha="abcdefghijklmnopqrstuvwxyz"; alpha+=alpha+alpha.toUpperCase()+alpha.toUpperCase(); for(i=0,result=""; i<sel.length; result+=(alpha.indexOf(sel.charAt(i))<0)? sel.charAt(i++): alpha.charAt(alpha.indexOf(sel.charAt(i++))+13)); void(alert(result));
The code looks like this:
else {
if(!sel)sel=prompt('Enter the text to ROT13','');
for(i=0,result=""; i < sel.length;
  result+=(alpha.indexOf(sel.charAt(i)) < 0)?
Changing the last line to void(prompt('result:', result)); makes the bookmarklet into a rot-13 writer also, where you can easily copy the rot-13 encoded text.
Here is my version of a Mozilla rot-13 decoder bookmarklet in one line for easy copy-and-pasting:

javascript:p=document.getSelection();if(!p)p=prompt('Text:',''); q=''; for(i=0;i<p.length;i++) {c=p.charCodeAt(i); q+=String.fromCharCode (c+((c<65)^(c<91)^(c<97)^(c<123)? (c-1)%32<13? 13:-13:0))}alert(q)

Paste this as the location of a bookmark, and you've got a rot13 decoding button. For the curious, an easier-to-read version of the same thing:
for(i=0; i<p.length; i++){
    c+((c<65)^(c<91)^(c<97)^(c<123)? // *1
    (c-1)%32<13?13:-13:0)            // *2

// *1 - true iff c represents an alphabet
// *2 - decide btwn move forward and loop around
Added functionality: works on selected text, a la Netscape Everything Search Button-style. Select a rot13 encoded text, and press the decoder button. If nothing is selected, a dialog box pops up asking you for text.

Test it here!
Guvf znl abg pbzr va unaql...

Log in or register to write something here or to contact authors.