diff --git a/CRC16Context.cs b/CRC16Context.cs index bbac567..e5b007d 100644 --- a/CRC16Context.cs +++ b/CRC16Context.cs @@ -148,7 +148,7 @@ namespace DiscImageChef.Checksums } for(int i = 0; i < fileStream.Length; i++) - localhashInt = (ushort)((localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ localhashInt & 0xff]); + localhashInt = (ushort)((localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)]); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; hash = BigEndianBitConverter.GetBytes(localhashInt); @@ -200,7 +200,7 @@ namespace DiscImageChef.Checksums } for(int i = 0; i < len; i++) - localhashInt = (ushort)((localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff]); + localhashInt = (ushort)((localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)]); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; hash = BigEndianBitConverter.GetBytes(localhashInt); diff --git a/CRC32Context.cs b/CRC32Context.cs index 485880f..f6c88de 100644 --- a/CRC32Context.cs +++ b/CRC32Context.cs @@ -73,7 +73,7 @@ namespace DiscImageChef.Checksums /// Length of buffer to hash. public void Update(byte[] data, uint len) { - for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ hashInt & 0xff]; + for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)]; } /// @@ -148,7 +148,7 @@ namespace DiscImageChef.Checksums } for(int i = 0; i < fileStream.Length; i++) - localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ localhashInt & 0xff]; + localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ (localhashInt & 0xff)]; localhashInt ^= CRC32_SEED; BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; @@ -200,7 +200,7 @@ namespace DiscImageChef.Checksums localTable[i] = entry; } - for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff]; + for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)]; localhashInt ^= CRC32_SEED; BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; diff --git a/CRC64Context.cs b/CRC64Context.cs index c15ad5e..c47a982 100644 --- a/CRC64Context.cs +++ b/CRC64Context.cs @@ -72,7 +72,7 @@ namespace DiscImageChef.Checksums /// Length of buffer to hash. public void Update(byte[] data, uint len) { - for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ hashInt & 0xff]; + for(int i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xff)]; } /// @@ -147,7 +147,7 @@ namespace DiscImageChef.Checksums } for(int i = 0; i < fileStream.Length; i++) - localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & 0xffL]; + localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ (localhashInt & 0xffL)]; localhashInt ^= CRC64_SEED; BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian; @@ -199,7 +199,7 @@ namespace DiscImageChef.Checksums localTable[i] = entry; } - for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff]; + for(int i = 0; i < len; i++) localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ (localhashInt & 0xff)]; localhashInt ^= CRC64_SEED; BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;