#include <swcipher.h>
Definition at line 33 of file swcipher.h.
Definition at line 49 of file swcipher.cpp.
void initialize(unsigned char *key, unsigned char keysize)
unsigned long size() const
static SWBuf personalize(const SWBuf &buf, bool encode)
void SWCipher::decode |
( |
void |
| ) |
|
|
virtual |
Definition at line 149 of file swcipher.cpp.
154 for (i = 0; i <
len; i++)
unsigned char decrypt(unsigned char b)
void SWCipher::encode |
( |
void |
| ) |
|
|
virtual |
Definition at line 130 of file swcipher.cpp.
134 for (
unsigned long i = 0; i <
len; i++)
unsigned char encrypt(unsigned char b=0)
char * SWCipher::getCipheredBuf |
( |
unsigned long * |
len = 0 | ) |
|
|
virtual |
Definition at line 112 of file swcipher.cpp.
116 if (ilen) *ilen =
len;
virtual void encode(void)
char * SWCipher::getUncipheredBuf |
( |
| ) |
|
|
virtual |
Definition at line 179 of file swcipher.cpp.
181 std::map<char, int> charHash;
182 for (
int i = 0; i < 62; ++i) charHash[lats[i]] = i;
186 for (
unsigned int i = 0; i < buf.
size() && segn < 5; ++i) {
187 if (buf[i] ==
'-') ++segn;
188 else segs[segn].
append(buf[i]);
191 SWBuf chkSum = segs[4];
192 if (segs[4].
size() < 5) segs[4].
size(4);
193 for (
int i = 0; i < 4; ++i) {
195 for (
unsigned int j = 0; j < segs[i].
size() && j < segs[0].
size(); ++j) {
196 char hash = charHash[segs[i][j]];
197 char obfusHash = charHash[segs[0][j%segs[0].size()]];
199 obfusHash = hash - (i ? obfusHash : 0);
200 if (obfusHash < 0) obfusHash = (62 + obfusHash);
203 obfusHash = hash + (i ? obfusHash : 0);
206 if (i) segs[i][j] = lats[(long)obfusHash];
207 csum += (
encode ? obfusHash : hash);
209 segs[4][i] = lats[csum%62];
210 if (result.
size()) result +=
"-";
211 result += (!
encode && !i ?
"" : segs[i].c_str());
virtual void encode(void)
SWBuf & append(const char *str, long max=-1)
unsigned long size() const
void SWCipher::setCipheredBuf |
( |
unsigned long * |
len, |
|
|
const char * |
buf = 0 |
|
) |
| |
|
virtual |
Definition at line 95 of file swcipher.cpp.
102 memcpy(
buf, ibuf, *ilen);
virtual void encode(void)
void SWCipher::setCipherKey |
( |
const char * |
key | ) |
|
|
virtual |
Definition at line 167 of file swcipher.cpp.
void initialize(unsigned char *key, unsigned char keysize)
unsigned long size() const
static SWBuf personalize(const SWBuf &buf, bool encode)
void SWCipher::setUncipheredBuf |
( |
const char * |
buf = 0 , |
|
|
unsigned long |
len = 0 |
|
) |
| |
|
virtual |
Definition at line 67 of file swcipher.cpp.
80 memcpy(
buf, ibuf, ilen);
virtual void decode(void)
unsigned long SWCipher::len |
|
private |
The documentation for this class was generated from the following files: