String hashcode from byte array
CodeKeep C# Feed Novembre 11th, 2008
Description: Handy for generating a unique (ish) filename from a file or array of bytes
Link: http://www.codekeep.net/snippets/780b5eed-ebfa-4450-b8c6-09170c186032.aspx
/// <summary>
/// Generates a hashcode for use as a filename from the given byte array
/// </summary>
public static String GenerateHashcodeFilename(Byte[] byteArray)
{
Byte[] hashVal = new MD5CryptoServiceProvider().ComputeHash(byteArray);
StringBuilder sb = new StringBuilder();
foreach (Byte b in hashVal)
{
sb.Append(b.ToString("X2"));
}
return String.Format("{0}", sb.ToString());
}






