I don’t understand few things in following code. Why the length is set to 16? What is the purpose of the ret variable?
Please explain.
I don’t understand this:
foreach (byte a in hash)
{
if (a < 16)
ret += "0" + a.ToString("x");
else
ret += a.ToString("x");
}
This
is a worse way of writing
Its purpose is to produce a string of length exactly 2 which is the hexadecimal form of the number
a. Since hex can go up to 15 with just one digit, the code reads “if it would fit in one digit, manually add a zero in front”.