]> icculus.org git repositories - taylor/freespace2.git/blob - src/globalincs/crypt.cpp
Initial revision
[taylor/freespace2.git] / src / globalincs / crypt.cpp
1 /*
2  * $Logfile: /Freespace2/code/GlobalIncs/crypt.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Files for cypting stuff
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:09  root
11  * Initial revision
12  *
13  * 
14  * 2     10/07/98 10:52a Dave
15  * Initial checkin.
16  * 
17  * 1     10/07/98 10:48a Dave
18  * 
19  * 2     3/30/98 9:33p Allender
20  * string encryption stuff for cheat codes
21  *
22  * $NoKeywords: $
23  */
24
25 #include <string.h>
26 #include "crypt.h"
27
28 char *jcrypt (char *plainstring)
29 {
30         int i,t,len;
31         static char cryptstring[CRYPT_STRING_LENGTH + 1];
32
33         len=strlen (plainstring);
34         if (len > CRYPT_STRING_LENGTH)
35                 len = CRYPT_STRING_LENGTH;
36    
37         for (i = 0;i < len; i++) {
38                 cryptstring[i]=0; 
39
40                 for (t = 0; t < len; t++) {
41                         cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
42                         cryptstring[i]%=90;
43                         cryptstring[i]+=33;
44                 }
45         }
46
47         cryptstring[i]=0;
48         return ((char *)cryptstring);
49 }