21 void Print(
const char* fmt, ...);
30 static void encypher(
long* v)
35 DWORD delta=0x9e3779b9;
40 y += (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1];
41 z += (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3];
48 static void decypher(
long* v)
53 DWORD delta=0x9e3779b9;
59 z-= (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3];
60 y-= (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1];
85 BYTE* work =
new(__FILE__,__LINE__) BYTE[len];
86 ZeroMemory(work, len);
87 CopyMemory(work, block.
data(), block.
length());
89 long* v = (
long*) work;
90 for (
int i = 0; i < len/8; i++) {
95 Text cypher((
const char*) work, len);
108 Print(
"WARNING: attempt to decrypt odd length block (len=%d)\n", len);
112 BYTE* work =
new(__FILE__,__LINE__) BYTE[len];
113 CopyMemory(work, block.
data(), len);
115 long* v = (
long*) work;
116 for (
int i = 0; i < len/8; i++) {
121 Text clear((
const char*) work, len);
128 static const char* codes =
"abcdefghijklmnop";
133 int len = block.
length() * 2;
134 char* work =
new(__FILE__,__LINE__)
char[len + 1];
136 for (
int i = 0; i < block.
length(); i++) {
137 BYTE b = (BYTE) (block.
data()[i]);
138 work[2*i] = codes[b>>4 & 0xf];
139 work[2*i+1] = codes[b & 0xf];
144 Text code(work, len);
154 int len = block.
length() / 2;
155 char* work =
new(__FILE__,__LINE__)
char[len + 1];
157 for (
int i = 0; i < len; i++) {
159 char l = block[2*i + 1];
161 work[i] = (u - codes[0]) << 4 |
167 Text clear(work, len);