1 #ifndef CHECKSUMS_GROUP
2 #define CHECKSUMS_GROUP
4 /*****************************************************************************\
6 * Name : checksums group *
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 1992-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 #include <basis/definitions.h>
21 A collection of useful checksum calculators.
24 namespace structures {
30 static basis::abyte byte_checksum(const basis::abyte *data, int length);
31 //!< simple byte-sized checksum based on additive roll-over.
33 static basis::un_int short_checksum(const basis::abyte *data, int length);
34 //!< simple shorty checksum based on additive roll-over.
36 static basis::un_short fletcher_checksum(const basis::abyte *data, int length);
37 //!< A positionally computed error detection value.
39 static basis::un_short rolling_fletcher_checksum(basis::un_short previous, const basis::abyte *data, int len);
40 //!< Fletcher checksums applied to streaming data.
41 /*!< this is not strictly a fletcher checksum, but it uses the normal
42 fletcher checksum on the specified data and XORs it with the "previous"
43 value of the checksum. this leads to a regenerable number that should
44 always be the same if done on the same data using the same chunking
45 factor (the "len"), although of course the last piece of data does not
46 have to be "len" bytes. */
48 static unsigned int bizarre_checksum(const basis::abyte *data, int length);
49 //!< A different type of checksum with somewhat unknown properties.
50 /*!< It attempts to be incorporate positioning of the bytes. */
52 static basis::un_int hash_bytes(const void *key_data, int key_length);
53 //!< returns a value that can be used for indexing into a hash table.
54 /*!< the returned value is loosely based on the "key_data" and the
55 "key_length" we are provided with. */