1
/******************************************************************************
2
* swcipher.cpp - code for class 'SWCipher'- a driver class that provides
12
/******************************************************************************
13
* SWCipher Constructor - Initializes data for instance of SWCipher
17
SWCipher::SWCipher(unsigned char *key) {
18
master.initialize(key, strlen((char *)key));
23
/******************************************************************************
24
* SWCipher Destructor - Cleans up instance of SWCipher
34
char *SWCipher::Buf(const char *ibuf, unsigned long ilen)
47
buf = (char *) malloc(ilen);
48
memcpy(buf, ibuf, ilen);
58
char *SWCipher::cipherBuf(unsigned long *ilen, const char *ibuf)
65
buf = (char *) malloc(*ilen+1);
66
memcpy(buf, ibuf, *ilen);
78
/******************************************************************************
79
* SWCipher::Encode - This function "encodes" the input stream into the
81
* The GetChars() and SendChars() functions are
82
* used to separate this method from the actual
86
void SWCipher::Encode(void)
90
for (unsigned long i = 0; i < len; i++)
91
buf[i] = work.encrypt(buf[i]);
97
/******************************************************************************
98
* SWCipher::Decode - This function "decodes" the input stream into the
100
* The GetChars() and SendChars() functions are
101
* used to separate this method from the actual
105
void SWCipher::Decode(void)
110
for (i = 0; i < len; i++)
111
buf[i] = work.decrypt(buf[i]);
118
/******************************************************************************
119
* SWCipher::setCipherKey - setter for a new CipherKey
123
void SWCipher::setCipherKey(const char *ikey) {
124
unsigned char *key = (unsigned char *)ikey;
125
master.initialize(key, strlen((char *)key));