berry@fortune.UUCP (06/25/83)
#N:fortune:4500006:000:1203
fortune!berry Jun 24 19:00:00 1983
Don't feel to bad, I'm sure most/all of the rest of us had
to ask at one time. When I did I received half a dozen letters on
what and how to undo rot13. The easiest way is:
tr a-zA-Z n-za-mN-ZA-M
or you can use the following program:
/*
* do a rot
*
* rot [shift factor] [files]
* shift factor defaults to 13
* files " " stdin
*/
#include <stdio.h>
#include <ctype.h>
#define ROT 13
main(argc, argv)
int argc;
char *argv[]; {
int rot;
char c;
if((argc < 2) || ((rot = atoi(argv[1])) == 0))
rot = ROT;
else {
argc--;
++argv;
}
while(*++argv) {
if(freopen(*argv, "r", stdin) == NULL)
perror(*argv);
else
rotate(rot);
}
if(argc == 1)
rotate(rot);
exit(0);
}
rotate(rot)
int rot;
{
char c;
while((c=getchar()) != EOF) {
if(isupper(c))
c = 'A' + (c - 'A' + rot) % 26;
else if(islower(c))
c = 'a' + (c - 'a' + rot) % 26;
putchar(c);
}
}
The above was received in one of the letters I received and then heavily
modified by me. Whoever sent it I appreciate it and apologize for
not having the foresight/courtesy to jot down your name to reference.
David W. Berry
hpda!fortune!berry
harpo!fortune!berry
ihnp4!fortune!berry
----------