From d0660472ebcdfb4121217fe2e3c65544f0be16ee Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 6 Nov 2024 12:45:53 -0500 Subject: [PATCH] Less hardcoding, I guess? --- SabreTools.Hashing/Crc/CrcTable.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SabreTools.Hashing/Crc/CrcTable.cs b/SabreTools.Hashing/Crc/CrcTable.cs index 12385d9..5e2bbd0 100644 --- a/SabreTools.Hashing/Crc/CrcTable.cs +++ b/SabreTools.Hashing/Crc/CrcTable.cs @@ -106,9 +106,9 @@ namespace SabreTools.Hashing.Crc for (int b = 0; b < 8; b++) { if (_definition.ReflectIn) - hash = (hash >> 1) ^ OptTable[0, (byte)(hash & 1) ^ ((byte)(data[offset] >> b) & 1)]; + hash = (hash >> _processBits) ^ OptTable[0, (byte)(hash & 1) ^ ((byte)(data[offset] >> b) & 1)]; else - hash = (hash << 1) ^ OptTable[0, (byte)((hash >> _bitShift) & 1) ^ ((byte)(data[offset] >> (7 - b)) & 1)]; + hash = (hash << _processBits) ^ OptTable[0, (byte)((hash >> _bitShift) & 1) ^ ((byte)(data[offset] >> (7 - b)) & 1)]; } } @@ -116,9 +116,9 @@ namespace SabreTools.Hashing.Crc else { if (_definition.ReflectIn) - hash = (hash >> 8) ^ OptTable[0, (byte)hash ^ data[offset]]; + hash = (hash >> _processBits) ^ OptTable[0, (byte)hash ^ data[offset]]; else - hash = (hash << 8) ^ OptTable[0, ((byte)(hash >> _bitShift)) ^ data[offset]]; + hash = (hash << _processBits) ^ OptTable[0, ((byte)(hash >> _bitShift)) ^ data[offset]]; } } }