[newbie] Formatting hash

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

In my program I once want to print a MD5- Hash I created to the user. But how can I convert this byte array to a human readable string, so that it looks like e.g.: 0d89c9f9834b3 etc.. Can anyone point this out

Thanks a lo
John
 
John said:
Hi,

In my program I once want to print a MD5- Hash I created to the user. But how can I convert this byte array to a human readable string, so that it looks like e.g.: 0d89c9f9834b3 etc.. Can anyone point this out?

Thanks a lot
John

System.Text.Encoding.ASCII.GetString()
 
Yeah, but that just gives me the ASCII representation of my string, and not a hex dump. Any ideas

John
 
Yeah, but that just gives me the ASCII representation of my string, and
not a hex dump. Any ideas?


array.ToString("x");

Could work (not tested). If not, you have to convert every single byte to a
hexstring using myint.ToString("x2");
 
John Fisher said:
In my program I once want to print a MD5- Hash I created to the user.
But how can I convert this byte array to a human readable string, so
that it looks like e.g.: 0d89c9f9834b3 etc.. Can anyone point this
out?

Have a look at Convert.ToString(byte[]). That will give a human
readable version, although not quite in the form you specified. Using
String.ToLower and String.Replace will get you to your example format
if you really want it though.
 
Back
Top