add optional mask parameter to crc32

This commit is contained in:
Phillip Stephens 2015-08-17 02:32:03 -07:00
parent d9b7151487
commit 7464c8e5eb
2 changed files with 3 additions and 3 deletions

View File

@ -7,7 +7,7 @@ namespace Athena
{ {
namespace Checksums namespace Checksums
{ {
atUint32 crc32(const atUint8* data, atUint64 length, atUint32 seed = 0xFFFFFFFF); atUint32 crc32(const atUint8* data, atUint64 length, atUint32 mask = 0xFFFFFFFF, atUint32 seed = 0xFFFFFFFF);
atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed = 0xFFFF, atUint16 final = 0); atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed = 0xFFFF, atUint16 final = 0);
atUint16 crc16(const atUint8* data, atUint64 length); atUint16 crc16(const atUint8* data, atUint64 length);
} }

View File

@ -8,7 +8,7 @@ namespace Athena
namespace Checksums namespace Checksums
{ {
atUint32 crc32(const atUint8* data, atUint64 length, atUint32 seed) atUint32 crc32(const atUint8* data, atUint64 length, atUint32 mask, atUint32 seed)
{ {
static const atUint32 crc32Table[256] = static const atUint32 crc32Table[256] =
{ {
@ -55,7 +55,7 @@ atUint32 crc32(const atUint8* data, atUint64 length, atUint32 seed)
while (length--) while (length--)
checksum = (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ data[pos++]]; checksum = (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ data[pos++]];
return checksum ^ seed; return checksum ^ mask;
} }
atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed, atUint16 final) atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed, atUint16 final)