]> icculus.org git repositories - taylor/freespace2.git/blob - src/globalincs/crypt.cpp
get rid of some platform specific stuff
[taylor/freespace2.git] / src / globalincs / crypt.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/GlobalIncs/crypt.cpp $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Files for cypting stuff
16  *
17  * $Log$
18  * Revision 1.3  2002/06/09 04:41:17  relnev
19  * added copyright header
20  *
21  * Revision 1.2  2002/05/07 03:16:45  theoddone33
22  * The Great Newline Fix
23  *
24  * Revision 1.1.1.1  2002/05/03 03:28:09  root
25  * Initial import.
26  *
27  * 
28  * 2     10/07/98 10:52a Dave
29  * Initial checkin.
30  * 
31  * 1     10/07/98 10:48a Dave
32  * 
33  * 2     3/30/98 9:33p Allender
34  * string encryption stuff for cheat codes
35  *
36  * $NoKeywords: $
37  */
38
39 #include <string.h>
40 #include "crypt.h"
41
42 char *jcrypt (char *plainstring)
43 {
44         int i,t,len;
45         static char cryptstring[CRYPT_STRING_LENGTH + 1];
46
47         len=strlen (plainstring);
48         if (len > CRYPT_STRING_LENGTH)
49                 len = CRYPT_STRING_LENGTH;
50    
51         for (i = 0;i < len; i++) {
52                 cryptstring[i]=0; 
53
54                 for (t = 0; t < len; t++) {
55                         cryptstring[i]^=(plainstring[t] ^ plainstring[i%(t+1)]);
56                         cryptstring[i]%=90;
57                         cryptstring[i]+=33;
58                 }
59         }
60
61         cryptstring[i]=0;
62         return ((char *)cryptstring);
63 }
64