home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include "cydec_proto.h"
-
- #define CYPHER_KEY 50
-
- static int cypher_len;
- static unsigned char encrypt_key,decrypt_key;
- static unsigned char *cypher_id="GameSmith Encrypted";
-
- /*********************************************************************/
-
- __stdargs int gs_identify_cypher(int len, unsigned char *cypher)
-
- {
- cypher_len=strlen(cypher_id);
- if (cypher_len & 1) /* cypher length MUST be even number */
- cypher_len++;
- if (len != cypher_len)
- return(0); /* cypher unrecognized */
- if (strcmp(cypher_id,cypher))
- return(0); /* cypher unrecognized */
- decrypt_key=CYPHER_KEY; /* init decryption key */
- return(1); /* OK! We know that one */
- }
-
- /*********************************************************************/
-
- __stdargs unsigned char *gs_cypher_block(int *len, int type)
-
- {
- encrypt_key=CYPHER_KEY; /* init encryption key */
- *len=strlen(cypher_id);
- if (*len & 1) /* cypher length MUST be even number */
- (*len)++;
- return(cypher_id);
- }
-
- /*********************************************************************/
-
- __stdargs void gs_encrypt_data(int len, unsigned char *data)
-
- {
- int cnt;
-
- for (cnt=0; cnt < len; cnt++)
- {
- data[cnt]=data[cnt]+encrypt_key;
- encrypt_key=data[cnt];
- }
- }
-
- /*********************************************************************/
-
- __stdargs void gs_decrypt_data(int len, unsigned char *data)
-
- {
- int cnt;
- unsigned char temp;
-
- for (cnt=0; cnt < len; cnt++)
- {
- temp=data[cnt];
- data[cnt]=data[cnt]-decrypt_key;
- decrypt_key=temp;
- }
- }
-