Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site burl.UUCP Path: utzoo!linus!philabs!cmcl2!floyd!clyde!burl!rcj From: rcj@burl.UUCP (R. Curtis Jackson) Newsgroups: net.puzzle Subject: Re: three spies Message-ID: <352@burl.UUCP> Date: Wed, 19-Oct-83 11:05:44 EDT Article-I.D.: burl.352 Posted: Wed Oct 19 11:05:44 1983 Date-Received: Thu, 20-Oct-83 07:56:23 EDT References: <534@ihuxw.UUCP> Organization: Western Electric, Burlington, NC Lines: 66 I have had three people ask me what rot 13 is, so I decided to (once again, for you net.jokes readers) explain: rot 13 is a method of encryption that is used to hide things from those who might not want to see them. Offensive jokes on the net are encrypted in this manner so that only those who want to read them have to do so. It is accomplished by adding 13 to the ascii value of each letter; this addition of 13 is wrapped around within each of the two (upper and lower case) character sets. For instance, 'c' + 13 ==> d e f g h i j k l m n o = 'p' 'T' + 13 ==> U V W X Y Z A B C D E F = 'G' etc. Here is a program that reads stdin and outputs stdout; it will encrypt/ decrypt any rot13 text. Because it is a filter, it can easily be used at the '?' prompt of readnews with the 's' option: ? s | rot13 It will take an argument for the rotation value -- but the default (and the standard for netnews, because it is easily reversible) is 13. NOTE: IF YOU ARE RUNNING ONE OF THE NEWER VERSIONS OF NEWS (I BELIEVE IT IS 2.10 AND UP), YOU CAN TYPE AN UPPER-CASE D ('D') TO THE '?' PROMPT OF READNEWS, AND IT WILL DECRYPT ONLY WHAT IS ENCRYPTED WITH ROT 13 AUTOMAGICALLY. It does not always work correctly, though; so you may have to back up with a '-' ('D' option does not accept a '-' modifier like 'f' and 'r' and 's'), then type 'D 13' to the prompt and it will perform the same function as the program below. Note that the 'D' option is NOT like the 's' option; you can save an article with 'D', but you lose the header and the only way to do it is 'D > filename'. ==================================================================== /* program to rotate the upper and lower case ascii character set */ #include #include main(argc,argv) int argc; char *argv[]; { int c; int rotation; if (argc > 1) { if (sscanf(argv[1],"%d",&rotation) != 1) exit(1); /* bad conversion */ } else rotation = 13; while (rotation<0) rotation += 26; while ( (c=getchar()) != EOF ) { if (isupper(c)) { putchar('A'+ (c-'A'+rotation) % 26 ); } else if (islower(c)) { putchar('a' + (c-'a'+rotation) % 26); } else putchar(c); } } -- The MAD Programmer -- 919-228-3814 (Cornet 291) alias: Curtis Jackson ...![ floyd clyde ihnp4 mhuxv ]!burl!rcj