From: CryptoManiac Date: Fri, 28 Aug 2015 14:06:33 +0000 (+0300) Subject: Hash:GetHashCode() X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=commitdiff_plain;h=4ef09413d32577c9c5aa67f790e3f7c7b21cbb00 Hash:GetHashCode() Now it's necessary because we want to use hash as key for dictionary. --- diff --git a/Novacoin/Hash.cs b/Novacoin/Hash.cs index 822cadd..bbb01bf 100644 --- a/Novacoin/Hash.cs +++ b/Novacoin/Hash.cs @@ -94,8 +94,15 @@ namespace Novacoin public override int GetHashCode() { - // It's a hash already, so any idea of trying to get its hashcode doesn't make any sense to me - throw new NotSupportedException(); + int hash = 17; + unchecked + { + foreach (var element in _hashBytes) + { + hash = hash * 31 + element.GetHashCode(); + } + } + return hash; } public int CompareTo(Hash item)