문제

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