Tags: EN

Did you know… that MD5 hash is a valid GUID?! 😲

/// <summary>
/// Convert string to Guid
/// </summary>
/// <param name="value">the string value</param>
/// <returns>the Guid value</returns>
public static Guid ConvertToMd5HashGUID(string value)
{
  // convert null to empty string - null can not be hashed
  if (value == null)
  {
    value = string.Empty;
  }

  // get the byte representation
  var bytes = Encoding.Default.GetBytes(value);

  // create the md5 hash
  MD5 md5Hasher = MD5.Create();
  byte[] data = md5Hasher.ComputeHash(bytes);

  // convert the hash to a Guid
  return new Guid(data);
}

 

Anders Hejlsberg on Channel 9 Live

I got to say this is my number 1 C# person on the planet and if not for Scott Gu he would be my number 1 person at Microsoft.

Every video with him is really really interesting. So is this one: http://player.microsoftpdc.com/Session/b3efbe56-08c0-4ea9-85ec-eb481c189abd/9654

I’d encourage every .NET developer to take some time and learn about the new async stuff comming in C# 5. Visual Studio’s Async page is a good place to start.

http://msdn.microsoft.com/en-us/vstudio/async.aspx