Skip to content

Instantly share code, notes, and snippets.

@wholroyd
Created October 15, 2014 14:36
Show Gist options
  • Save wholroyd/6af0c13f5a8c64bc5670 to your computer and use it in GitHub Desktop.
Save wholroyd/6af0c13f5a8c64bc5670 to your computer and use it in GitHub Desktop.
Hashing a string into a Guid
// using System.Security.Cryptography
var str = “William Holroyd”;
var byt = Encoding.UTF8.GetBytes(str);
var hash = MD5.Create().ComputeHash(byt);
var guid = new Guid(hash);
// guid will always have a value of "ead7ab16-6d5b-0fa0-73b7-9fe85b675f83"
// for the input of “William Holroyd” provided above. This value will always
// be produced no matter what machine the code is executed on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment