2 * $Logfile: /Freespace2/code/Cryptstring/cryptstring.cpp $
7 * Applet for crypting strings.
10 * Revision 1.2 2002/05/07 03:16:43 theoddone33
11 * The Great Newline Fix
13 * Revision 1.1.1.1 2002/05/03 03:28:08 root
17 * 2 10/23/98 6:21p Dave
27 int main(int argc, char **argv)
33 printf("Usage: cryptstring <string1> <string2> ...\n");
34 printf("Output will be <crypt1> <crypt2>\n");
38 for ( i = 1; i < argc; i++ ) {
42 // if the length of the string is greater than the number of crypted symbols we
43 // return, then pass only the maximum length
44 if ( strlen(s) > CRYPT_STRING_LENGTH )
45 s += (strlen(s) - CRYPT_STRING_LENGTH);
47 crypt_string = jcrypt(s);
48 printf("%s\n", crypt_string);
54 char *jcrypt (char *plainstring)
57 static char cryptstring[CRYPT_STRING_LENGTH + 1];
59 len=strlen (plainstring);
60 if (len > CRYPT_STRING_LENGTH)
61 len = CRYPT_STRING_LENGTH;
63 for (i = 0;i < len; i++) {
66 for (t = 0; t < len; t++) {
67 cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
74 return ((char *)cryptstring);