Back to index

tetex-bin  3.0
t1crypt.c
Go to the documentation of this file.
00001 unsigned short int r;
00002 unsigned short int c1 = 52845;
00003 unsigned short int c2 = 22719;
00004 
00005 #include "t1crypt.h"
00006 
00007 unsigned char t1_encrypt(unsigned char plain)
00008 {
00009   unsigned char cipher;
00010   cipher = (plain ^ (r >> 8));
00011   r = (cipher+r)*c1 + c2;
00012   return cipher;
00013 }
00014 
00015 void t1_crypt_init (unsigned short int key)
00016 {
00017   r = key;
00018 }
00019 
00020 unsigned char t1_decrypt(unsigned char cipher)
00021 {
00022   unsigned char plain;
00023   plain = (cipher ^ (r>>8));
00024   r = (cipher+r)*c1 + c2;
00025   return plain;
00026 }