ROT-13

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 0 people | Log in to rate

Ranked #10,954 in How-To, #116,688 overall

A (very) simple method of encryption

ROT-13 (rotate 13) is a simple text encoding technique, a variation on the Caesar cypher used by the ancient Romans. To encode a message in ROT-13, simply replace each letter by the letter 13 positions after it in the alphabet (when you pass "Z", just go back to "A" and continue.)

By choosing 13 as the offset, the code is self-decrypting, which makes it very simple to program for use on computers. To encode a message, you run the message through the encoder. To decode, you simply run the encoded message through the same decoder again.

The Table 

For those who like to do things manually, here is a table for using the ROT-13 cipher. Just lookup the letter you are trying to encode or decode. However, this is really tedious, and a program that decodes and encodes is much easier to use.

ROT-13 Lookup Table For Manual Decoding 

Encryption Table

This is a simple table to look up the proper values to encode and decode ROT-13. You really don't want to do it manually, unless you have a lot of time on your hands, or maybe some monks who need a break from transcribing scrolls.
  1. A - N
  2. B - O
  3. C - P
  4. D - Q
  5. E - R
  6. F - S
  7. G - T
  8. H - U
  9. I - V
  10. J - W
  11. K - X
  12. L - Y
  13. M - Z
  14. N - A
  15. O - B
  16. P - C
  17. Q - D
  18. R - E
  19. S - F
  20. T - G
  21. U - H
  22. V - I
  23. W - J
  24. X - K
  25. Y - L
  26. Z - M

Available Decoders 

Basically, in C (and C++), you can just add 13 to any letter and then check if you've rolled past 'Z' or 'z', depending on case. If so, adjust. The same code works as an encoder and a decoder, since the offset is the same.

A Java version is included in the lens.

Many newsreader programs had the ROT-13 decoder built-in, since it was a standard way to publish "spoilers" without printing the text where it could be easily stumbled across. If you marked a section as a spoiler and rot-13'd the text, then the reader would have to take an action in order to decode the text.

Sample Java Code 

This is not optimized code but it works.

package com.xriva.code;

public class Rot13
{


public static String rot13(String message)
{


String coded = "";


for (int x = 0; x < message.length(); x++)
{
char c = message.charAt(x);


if (Character.isLowerCase(c))
{
c += 13;
if (c > 'z')
c -= ('z' - 'a') + 1;
}


if (Character.isUpperCase(c))
{
c += 13;
if (c > 'Z')
c -= ('Z' - 'A') + 1;
}


coded += c;
}

return coded;
}
}

Related 

ROT13
Old, but useful reference for programmers
ROT13
ROT13 From Wikipedia, the free encyclopedia

Some Uses 

A Real-World Example

ROT-13 can be a useful method to create "cool-sounding" user names. I used it in a (rather) futile effort to impress my son when he was about five.

For example, "Kevin" becomes "xriva" which I have used as a name for my personal website at www.xriva.com.

I have received notes from other Kevins because I registered "xriva" first, so apparently I'm not the only one who thought of this.

Cryptography Books 

There was an error connecting to the Amazon web service. Please try again. Sorry, there are no results available from Amazon.

by SparkyDad

Kevin is President of Sparky's Pals (a Dallas, Texas 501(c)(3) non-profit humane education corporation dedicated to assisting those who help
pets find... (more)

Explore related pages

Create a Lens!