2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Cryptstring/cryptstring.cpp $
15 * Applet for crypting strings.
18 * Revision 1.3 2002/06/09 04:41:15 relnev
19 * added copyright header
21 * Revision 1.2 2002/05/07 03:16:43 theoddone33
22 * The Great Newline Fix
24 * Revision 1.1.1.1 2002/05/03 03:28:08 root
28 * 2 10/23/98 6:21p Dave
38 int main(int argc, char **argv)
44 printf("Usage: cryptstring <string1> <string2> ...\n");
45 printf("Output will be <crypt1> <crypt2>\n");
49 for ( i = 1; i < argc; i++ ) {
53 // if the length of the string is greater than the number of crypted symbols we
54 // return, then pass only the maximum length
55 if ( strlen(s) > CRYPT_STRING_LENGTH )
56 s += (strlen(s) - CRYPT_STRING_LENGTH);
58 crypt_string = jcrypt(s);
59 printf("%s\n", crypt_string);
65 char *jcrypt (char *plainstring)
68 static char cryptstring[CRYPT_STRING_LENGTH + 1];
70 len=strlen (plainstring);
71 if (len > CRYPT_STRING_LENGTH)
72 len = CRYPT_STRING_LENGTH;
74 for (i = 0;i < len; i++) {
77 for (t = 0; t < len; t++) {
78 cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
85 return ((char *)cryptstring);