For Programmers: Free Programming Magazines  


Home > Archive > C# > January 2006 > Problem converting a byte array to a string with UTF8 encoding.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem converting a byte array to a string with UTF8 encoding.
PrettySneaky@gmail.com

2006-01-29, 6:59 pm


I'm writing a program which is supposed to save a hashvalue of byte[]
array. My code looks like this.

byte[] hashValue = sha.ComputeHash(Buffer);
AFile.Write(Encoding.UTF8.GetString(hashValue));

My problem is that even though hashValue.Length = 20, the getstring
method creates a string with less the 20 characters. Anyone know what
I'm doing wrong?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com