2 * $Logfile: /Freespace2/code/Cryptstring/cryptstring.cpp $
7 * Applet for crypting strings.
10 * Revision 1.1 2002/05/03 03:28:08 root
14 * 2 10/23/98 6:21p Dave
24 int main(int argc, char **argv)
30 printf("Usage: cryptstring <string1> <string2> ...\n");
31 printf("Output will be <crypt1> <crypt2>\n");
35 for ( i = 1; i < argc; i++ ) {
39 // if the length of the string is greater than the number of crypted symbols we
40 // return, then pass only the maximum length
41 if ( strlen(s) > CRYPT_STRING_LENGTH )
42 s += (strlen(s) - CRYPT_STRING_LENGTH);
44 crypt_string = jcrypt(s);
45 printf("%s\n", crypt_string);
51 char *jcrypt (char *plainstring)
54 static char cryptstring[CRYPT_STRING_LENGTH + 1];
56 len=strlen (plainstring);
57 if (len > CRYPT_STRING_LENGTH)
58 len = CRYPT_STRING_LENGTH;
60 for (i = 0;i < len; i++) {
63 for (t = 0; t < len; t++) {
64 cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
71 return ((char *)cryptstring);