April 08, 2016 calculating CRC32 | ||||
---|---|---|---|---|
| ||||
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. |
Copyright © 1999-2021 by the D Language Foundation