Re: calculating CRC32

2016-04-08 Thread zabruk70 via Digitalmars-d-learn

print result as hex
try to xor result with 0x



calculating CRC32

2016-04-08 Thread chrisalex via Digitalmars-d-learn
I'm trying to calculate CRC32 and it keeps giving me the wrong 
result.



void main(string[] args)
{
   CRC32Digest test = new CRC32Digest();
   ubyte[] data = [1,5,2,3,4];
   test.put(data);
   auto data2 = test.finish();
   writeln((data2[0] << 24) | (data2[1] << 16) | ((data2[2]) << 
8) | (data2[3]));
   writeln((data2[0]) | (data2[1] << 8) | ((data2[2]) << 16) | 
(data2[3] << 24));

}


this writes out


728586467
-480744149


but when calculating CRC32 with java, I get


3814223147


Not sure what I'm doing wrong. I tried reversing data[] as well.