]> icculus.org git repositories - btb/d2x.git/blob - main/crypt.c
remove rcs tags
[btb/d2x.git] / main / crypt.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  *
16  * Encryption function for the cheat codes
17  *
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include <conf.h>
22 #endif
23
24 //#include <time.h>
25 //#include <stdlib.h>
26 #include <string.h>
27
28 //#include "inferno.h"
29
30 char *jcrypt (char *plainstring)
31 {
32         int i, t, len;
33         static char cryptstring[20];
34
35         len=strlen (plainstring);
36         if (len > 8)
37                 len = 8;
38
39         for (i = 0; i < len; i++)
40         {
41                 cryptstring[i] = 0;
42
43                 for (t = 0; t < 8; t++)
44                 {
45                         cryptstring[i] ^= (plainstring[t] ^ plainstring[i % (t + 1)]);
46                         cryptstring[i] %= 90;
47                         cryptstring[i] += 33;
48                 }
49         }
50         cryptstring[i] = 0;
51         return ((char *)cryptstring);
52 }