On Sun, 21 Sep 2003, Nikhil Joshi wrote:
Hi! I've just downloaded offensive fortune-mod cookies. they seem to be encoded . Does anyone know about the encoding algorithm?
man strfile gave that the alphabets are rotated 13 positions. so i wrote a program , it now works. Can a shell script be written to achieve the same purpose ?
#include <stdio.h> #include <stdlib.h> #include <ctype.h> int main (int argc, char *argv[]) { FILE *in; char ch; if (argc > 1) {
{ in = fopen (argv[1], "r"); if (in == NULL)
{ perror (argv[1]); exit (1); }
}
while ((ch = fgetc (in)) != EOF) { if (isalpha (ch) != 0) { if (isupper (ch) != 0) if ((int) ch > ((int) ('Z') - 13)) ch = (int) ch - 13; else ch = (int) ch + 13;
if (islower (ch) != 0) if ((int) ch > ((int) ('z') - 13)) ch = (int) ch - 13; else ch = (int) ch + 13;
} printf ("%c", ch);
} fclose (in); } else printf ("Usage: %s filename\n", argv[0]); return 0; }