home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / wanted / 4270 < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.4 KB  |  55 lines

  1. Newsgroups: comp.sources.wanted
  2. Path: sparky!uunet!spsgate!mogate!newsgate!chdasic.sps.mot.com!dichter
  3. From: dichter@chdasic.sps.mot.com (Carl Dichter)
  4. Subject: Re: ROT13 Encryption
  5. Message-ID: <1992Sep9.175552.18632@newsgate.sps.mot.com>
  6. Sender: usenet@newsgate.sps.mot.com
  7. Nntp-Posting-Host: 223.197.55.10
  8. Organization: SPS
  9. References:  <139@rd821.UUCP>
  10. Date: Wed, 9 Sep 1992 17:55:52 GMT
  11. Lines: 42
  12.  
  13. In article <139@rd821.UUCP>, a036450@rd821.UUCP (Bob Goldrich) writes:
  14. |> Could someone give me the basics on ROT13 encryption.  Is there
  15. |> source code available anywhere?  If so, where?
  16. |>                   -Bob Goldrich  a036450@rd821.gleason.com
  17.  
  18. ROT13 is a very basic encryption (as someone points out in another post)
  19. and I don't recommend it for anything important. But, if you still want it,
  20. here's a little c program I wrote as a pipe:
  21. --------------- rot13.c -----------------------
  22. #include <ctype.h>
  23. main()
  24. {
  25.     char    buf[256+1], c;
  26.     int    i, was_lower = 0;
  27.  
  28.     while(gets(buf)) {
  29.         for(i=0; buf[i]; i++) {
  30.             c = buf[i];
  31.             if(isalpha(c)) {
  32.                 if(islower(c)) {
  33.                     c = toupper(c);
  34.                     was_lower++;
  35.                 }
  36.                 else
  37.                     was_lower = 0;
  38.                 c -= 13;
  39.                 if(c < 'A') {
  40.                     c += 26;
  41.                 }
  42.                 if( was_lower && isupper(c))
  43.                     c = tolower(c);
  44.             }
  45.             putchar(c);
  46.         }
  47.         putchar('\n');
  48.     }
  49. }
  50.  
  51. ----------------------
  52. Carl R. Dichter             "iwannanugui"
  53. Motorola ASIC Division
  54. email: dichter@chdasic.sps.mot.com
  55.