ROT13

This is a page of toy scripts to perform the old rot13 encryption trick. It simply rotates each letter 13 characters. Thus Rot13 becomes Ebg13 which again becomes Rot13.

Perl version: PKZip, Gzip last updated 2005-05-14.
This is the Perl version I wrote because my Mac OS 10.2.8 PowerBook does not have rot13 installed. Being a lazy programmer I wrote a quick Perl script, which eventually became a full featured rot13. It has the following behavior:

  • With no arguments it acts as a filter and performs a read, rot13, print cycle.
  • With a file as an argument it will read the file, rot13 each line and print it to STDOUT.
  • With non file arguments it will rot13 each argument and print them all on one line to STDOUT.
  • With the argument -h, -help or --help it will print a simple help text.
Note: Argument processing is very simplistic and the action picked is based on the first argument.

Bourne Shell version: PKZip, Gzip last updated 2005-05-14.
I wrote this version for fun. It behaves much the same was as the Perl version but uses nothing but plain Bourne shell and Unix utilities. tr is used for arguments and for lines when acting as a filter. Sed is used for files.

Awk version: PKZip, Gzip last updated 2005-05-14.
I wrote this version an an introduction to awk and for fun. It behaves much the same was as the Perl version except it only works on files or as a filter. It is written in pure old fashioned awk and should work with almost any version of awk. (I even avoided the split operator to make it more portable.)

Last updated: 2007-05-30.

Back

Created with VIM. Valid HTML 4.01 Transitional.