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