{"id":330,"date":"2020-12-29T13:30:13","date_gmt":"2020-12-29T13:30:13","guid":{"rendered":"https:\/\/michaeljohnsteiner.com\/?p=330"},"modified":"2020-12-29T13:30:13","modified_gmt":"2020-12-29T13:30:13","slug":"sha16512-cs","status":"publish","type":"post","link":"https:\/\/michaeljohnsteiner.com\/index.php\/2020\/12\/29\/sha16512-cs\/","title":{"rendered":"Sha16512.cs"},"content":{"rendered":"\n<p>Variable 16Bit to 512Bit Hashing Algorithm <\/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=\"\">using System;\nusing System.Security.Cryptography;\n[Serializable]\npublic class Sha16512 : HashAlgorithm\n{\n    private int           _bitWidth;\n    private SHA512Managed _hash = new SHA512Managed();\n    public Sha16512(int bitWidth)\n    {\n        if (bitWidth &lt; 16 || bitWidth > 512)\n            throw new ArgumentException($\"Bit Width {bitWidth} must be between 16 and 512.\");\n        _bitWidth = bitWidth;\n    }\n    public override int HashSize => _bitWidth;\n    public override void Initialize()\n    {\n    }\n    protected override void HashCore(byte[] bytes, int ibStart, int cbSize)\n    {\n        var buf = bytes.SubByte(ibStart, cbSize);\n        HashValue = _hash.ComputeHash(buf).SubByte(0, _bitWidth >> 3);\n    }\n    protected override byte[] HashFinal()\n    {\n        return (byte[]) HashValue.Clone();\n    }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Variable 16Bit to 512Bit Hashing Algorithm<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[148,149,161,76,162],"_links":{"self":[{"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/posts\/330"}],"collection":[{"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/comments?post=330"}],"version-history":[{"count":1,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/posts\/330\/revisions"}],"predecessor-version":[{"id":331,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/posts\/330\/revisions\/331"}],"wp:attachment":[{"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/media?parent=330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/categories?post=330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaeljohnsteiner.com\/index.php\/wp-json\/wp\/v2\/tags?post=330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}