質問

I'm trying to find a CRC32 computation algorythm that output data in positive 8-character HEX (like winrar CRC for example).

All algorythms found return a positive/negative integer that I don't know how to handle...

役に立ちましたか?

解決

I'll bet that all of the CRC32 algorithms you found return a 32-bit integer (e.g. int or uint). When you view it, you're probably viewing it as a base-10 number. By viewing I mean formatting the integer as a string without passing any format options to Int32.ToString or String.Format.

If you were to put Visual Studio into Hexadecimal View, you would get your "expected" output. The algorithms are all correct in this case, however, it is your expectation that is incorrect!

Instead, use a Number Format which produces the string representation you desire:

uint crc32 = Crc32Class.GetMeAValue(data);

// For example, we'll write base-10 and base-16 the output to the console
Console.WriteLine("dec: {0}", crc32);
Console.WriteLine("hex: {0:X8}", crc32);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top