Result value small and capital character are the same? How to get return value with small character? #22
Replies: 1 comment
-
the CRC of an array of bytes is a number (not a string). this may be confusing to some people not familiar with number systems other than base 10. The hexidecimal (base 16) number 0x3AD00FD2 is 986714066 in decimal (base 10). furthermore 3AD00FD2 and 3ad00fd2 are the same number because numbers unlike letters do not have capitals or lowercase versions of themselves (technically). With base 16 letters from the alphabet are used to represent values 10 through 16 (a-f/A-F) but whether you use the capital or lowercase A/a is always the value for 10, B/b is always the value for 11 and so on... https://en.wikipedia.org/wiki/Radix to get the upper / lower case hexidecimal representation of the number in .net you use the standard .net format string for hex (scroll towards the bottom search for "x"). to view this / use this, simply create a console application and use the following code. using the "x" format will return a-f in lower case. "X" will return A-F in uppercase. var crc = 0x3AD00FD2;
var lowerCased = $"{crc:x8}";
var upperCased = $"{crc:X8}";
Console.WriteLine(lowerCased);
Console.WriteLine(upperCased); regardless they're the same number. ;) cheers. |
Beta Was this translation helpful? Give feedback.
-
// using text
var text = "I am string content";
// convert text to a byte array
var textBuffer = System.Text.Encoding.UTF8.GetBytes ( text );
// get the CRC for the text
var textCrc = NullFX.CRC.Crc32.ComputeChecksum ( textBuffer );
Console.WriteLine ( "Text CRC: {0:X8}", textCrc );
How to get the result string with small character instead of capital character.
for "I am string content"
3ad00fd2 instad of value "3AD00FD2"
I check from online this site the result are return with small character CRC32 value.
Beta Was this translation helpful? Give feedback.
All reactions