{"id":262,"date":"2018-10-03T12:42:31","date_gmt":"2018-10-03T10:42:31","guid":{"rendered":"https:\/\/spurgius.com\/blog\/?p=262"},"modified":"2019-09-27T22:24:11","modified_gmt":"2019-09-27T20:24:11","slug":"did-you-know-that-md5-hash-is-a-valid-guid","status":"publish","type":"post","link":"https:\/\/spurgius.com\/blog\/2018\/10\/03\/did-you-know-that-md5-hash-is-a-valid-guid\/","title":{"rendered":"Did you know&#8230; that MD5 hash is a valid GUID?! \ud83d\ude32"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\/\/\/ &lt;summary&gt;\n\/\/\/ Convert string to Guid\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=\"value\"&gt;the string value&lt;\/param&gt;\n\/\/\/ &lt;returns&gt;the Guid value&lt;\/returns&gt;\npublic static Guid ConvertToMd5HashGUID(string value)\n{\n  \/\/ convert null to empty string - null can not be hashed\n  if (value == null)\n  {\n    value = string.Empty;\n  }\n\n  \/\/ get the byte representation\n  var bytes = Encoding.Default.GetBytes(value);\n\n  \/\/ create the md5 hash\n  MD5 md5Hasher = MD5.Create();\n  byte[] data = md5Hasher.ComputeHash(bytes);\n\n  \/\/ convert the hash to a Guid\n  return new Guid(data);\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\/ &lt;summary&gt; \/\/\/ Convert string to Guid \/\/\/ &lt;\/summary&gt; \/\/\/ &lt;param name=&#8221;value&#8221;&gt;the string value&lt;\/param&gt; \/\/\/ &lt;returns&gt;the Guid value&lt;\/returns&gt; public static Guid ConvertToMd5HashGUID(string value) { \/\/ convert null to empty string &#8211; null can not be hashed if (value == null) { value = string.Empty; } \/\/ get the byte representation var bytes = Encoding.Default.GetBytes(value); \/\/ [&hellip;]<\/p>\n<a role=\"link\" class=\"rtp-readmore\" title=\"Read more on Did you know&#8230; that MD5 hash is a valid GUID?! \ud83d\ude32\" href=\"https:\/\/spurgius.com\/blog\/2018\/10\/03\/did-you-know-that-md5-hash-is-a-valid-guid\/\" rel=\"nofollow\">Read More &rarr;<\/a>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[13,10],"_links":{"self":[{"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/posts\/262"}],"collection":[{"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":2,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":264,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/posts\/262\/revisions\/264"}],"wp:attachment":[{"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spurgius.com\/blog\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}