I'm trying to generate a CRC32 checksum for the Kraken exchange's orderbooks as described here. I found another post in SO that referenced this Github file in order to generate the CRC32 checksum. The issue I have is that I need to generate the checksum based off an input string, where all of the checksum functions I've found take a byte[] as an input.
I tried converting the string to a byte[], but it doesn't give me the expected result that I should be getting as per the Kraken docs.
string inputString = "50055005010500501550050205005025500503050050355005040500504550050505005000500499550049905004980500497550049705004965500496050049555004950500";
Crc32 crc32 = new Crc32();
var byteArr = crc32.ComputeHash(Encoding.ASCII.GetBytes(inputString));
Console.WriteLine(Encoding.ASCII.GetString(byteArr));
The value this logs will be ":??", where as I'm supposed to be getting "974947235".
Clearly, I must be doing something completely wrong here. What am I missing?
ComputeHashreturnsbyte[], so you will get four bytes back. Your974947235becomes in hex3a, 1c, 83, a3. Or58, 28, 131, 163in decimal. Trying to print random bytes as characters can only lead to angst and frustration. Print them as numbers. Note that 58 is the colon (":") character, so in fact your first character is correct.By the way, there are many CRC-32's, but you seem to have stumbled on to the correct one, as the string you provided does indeed result in the CRC-32/ISO-HDLC:
974947235.