19 using namespace basis;
25 unsigned int checksums::bizarre_checksum(
const abyte *data,
int length)
28 for (
int i = 0; i < length; i++) sum += data[i] % 23 + i % 9;
30 return (
unsigned int)sum;
39 const abyte *buffer = data;
42 sum1 += int(*buffer++);
44 if (sum1 > 255) sum1++;
48 if (sum1 == 255) sum1 = 0;
58 {
return previous ^ fletcher_checksum(data, len); }
60 abyte checksums::byte_checksum(
const abyte *data,
int length)
63 for (
int i = 0; i < length; i++) to_return +=
abyte(data[i]);
70 for (
int i = 0; i < length; i++) to_return += data[i];
74 basis::un_int checksums::hash_bytes(
const void *key_data,
int key_length)
76 if (!key_data)
return 0;
77 if (!key_length)
return 0;
80 abyte hashed[4] = { 0, 0, 0, 0 };
83 for (
int i = 0; i < key_length; i++) {
85 hashed[fill_posn] = hashed[fill_posn] + our_key[i];
87 if (fill_posn >= 4) fill_posn = 0;
89 hashed[fill_posn] = hashed[fill_posn] + (our_key[i] / 4);
93 for (
int j = 0; j < 4; j++) to_return = (to_return << 8) + hashed[j];
Constants and objects used throughout HOOPLE.
The guards collection helps in testing preconditions and reporting errors.
unsigned char abyte
A fairly important unit which is seldom defined...
unsigned int un_int
Abbreviated name for unsigned integers.
unsigned short un_short
Abbreviated name for unsigned short integers.
A dynamic container class that holds any kind of object via pointers.
const int HIGHEST_MOD_VALUE