Q:

C# - Converting a String with Length 128 to a 64 bytes array to compare with SHA-512's 64 bytes array

I am trying to get a 64 bytes array of my hashed password so I can match it against the salted and hashed (SHA-512) password.
I am currently storing the hashed password in a MySql database using a VARCHAR(128).
So I am storing for example 406f2c25c99fa980992a9704878072485bcca1316b46b3d6a05bbe468a87a8bda82db6ea44a95746d96519a296463175c8a584e49b86d94bd4a542ac03fb6dd7 in the database.
When I retrieve that value as a String using C#, its length is 128.
I have tried several Encodings to get the byte array from that string, but i never get a 64 bytes one to even try to match it against the salted and hashed password's 64 bytes array.
Had the same issue with SHA-256 (couldn't get a 32 bytes array).
Thanks a lot!

A:

You are correct that SHA-512 returns a 64 byte value. However, in your database, you're storing a hexadecimal string representation of that 64 byte value, which requires twice as many bytes.
For example, consider the case when you have a single byte with a value of 255. As an unsigned integer, 255 can be stored in one byte, but the hexadecimal string representation (FF), requires 2 bytes.

