{"id":4640,"date":"2021-02-18T09:02:35","date_gmt":"2021-02-18T08:02:35","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=4640"},"modified":"2021-09-21T08:58:44","modified_gmt":"2021-09-21T07:58:44","slug":"generate-pincode-from-guid","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/generate-pincode-from-guid\/","title":{"rendered":"Generate static Pincode From Guid"},"content":{"rendered":"\n<p>For simple verification without an extra field<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var guidStr = Guid.Parse(\"890a1537-212f-4366-8d1d-95075b9245c4\").ToString();\n\nguidStr.Aggregate(0, (acc, x) => (acc + x * 1354) % 10000).ToString().PadLeft(4, '0');\n\n\/\/ Results in: 7560\n\/\/ Where 1354 can be changed per case\n\/\/ And 10000 and PadLeft 4 to e.g. 100000 and 5 for codes with a length of 5\n\nguidStr.Aggregate(0, (acc, x) => (acc + x * 1354) % 100000).ToString().PadLeft(5, '0');\n\/\/ Results in: 97560\n\n\/\/ Test some codes\nfor(int i=0;i&lt;100;i++)\n{\n\tConsole.WriteLine(Guid.NewGuid().ToString().Aggregate(0, (acc, x) => (acc + x * 1351) % 100000).ToString().PadLeft(5, '0') );\n}\n\n\/\/ Examples:\n\n05923\n00545\n19459\n34294\n92361\n41127\n80150\n23434\n82904\n11353\n55910\n42374\n55962\n38321\n09976\n45128\n45154\n62639\n51883\n62665\n19537\n23538\n26110\n26136\n54559\n08625\n\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For simple verification without an extra field<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4640","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=4640"}],"version-history":[{"count":7,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4640\/revisions"}],"predecessor-version":[{"id":5324,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4640\/revisions\/5324"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=4640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=4640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=4640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}