Created
October 15, 2014 14:36
-
-
Save wholroyd/6af0c13f5a8c64bc5670 to your computer and use it in GitHub Desktop.
Hashing a string into a Guid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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