mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Corrected poly and endian issues.
This commit is contained in:
@@ -46,12 +46,8 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
public class CRC32Context
|
||||
{
|
||||
//const UInt32 crc32Poly = 0xEDB88320;
|
||||
//const UInt32 crc32Seed = 0xFFFFFFFF;
|
||||
|
||||
const UInt32 crc32Poly = 0xD8018001;
|
||||
const UInt32 crc32Seed = 0x00000000;
|
||||
|
||||
const UInt32 crc32Poly = 0xEDB88320;
|
||||
const UInt32 crc32Seed = 0xFFFFFFFF;
|
||||
|
||||
UInt32[] table;
|
||||
UInt32 hashInt;
|
||||
@@ -102,6 +98,7 @@ namespace DiscImageChef.Checksums
|
||||
public byte[] Final()
|
||||
{
|
||||
hashInt ^= crc32Seed;
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
return BigEndianBitConverter.GetBytes(hashInt);
|
||||
}
|
||||
|
||||
@@ -113,6 +110,7 @@ namespace DiscImageChef.Checksums
|
||||
hashInt ^= crc32Seed;
|
||||
StringBuilder crc32Output = new StringBuilder();
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
for (int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++)
|
||||
{
|
||||
crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
||||
@@ -160,6 +158,7 @@ namespace DiscImageChef.Checksums
|
||||
for (int i = 0; i < fileStream.Length; i++)
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[fileStream.ReadByte() ^ localhashInt & 0xff];
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BitConverter.GetBytes(localhashInt);
|
||||
|
||||
StringBuilder crc32Output = new StringBuilder();
|
||||
@@ -213,6 +212,7 @@ namespace DiscImageChef.Checksums
|
||||
for (int i = 0; i < len; i++)
|
||||
localhashInt = (localhashInt >> 8) ^ localTable[data[i] ^ localhashInt & 0xff];
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BitConverter.GetBytes(localhashInt);
|
||||
|
||||
StringBuilder crc32Output = new StringBuilder();
|
||||
@@ -237,3 +237,4 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user