summary refs log tree commit diff
path: root/crypto/src/util/Arrays.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-03-24 22:42:30 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-03-24 22:42:30 +0700
commit813e5dca6dc23eb82008b1658f44071a8a8a3717 (patch)
tree6c32d543f35abe909583e86fa836d33bdbc55e19 /crypto/src/util/Arrays.cs
parentCustom curves for secp128r1 and secp160r1/r2/k1 (diff)
downloadBouncyCastle.NET-ed25519-813e5dca6dc23eb82008b1658f44071a8a8a3717.tar.xz
Add GetHashCode methods for ulong[]
Diffstat (limited to 'crypto/src/util/Arrays.cs')
-rw-r--r--crypto/src/util/Arrays.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index 8614baead..abea234a7 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -311,6 +311,48 @@ namespace Org.BouncyCastle.Utilities
             return hc;
         }
 
+        [CLSCompliantAttribute(false)]
+        public static int GetHashCode(ulong[] data)
+        {
+            if (data == null)
+                return 0;
+
+            int i = data.Length;
+            int hc = i + 1;
+
+            while (--i >= 0)
+            {
+                ulong di = data[i];
+                hc *= 257;
+                hc ^= (int)di;
+                hc *= 257;
+                hc ^= (int)(di >> 32);
+            }
+
+            return hc;
+        }
+
+        [CLSCompliantAttribute(false)]
+        public static int GetHashCode(ulong[] data, int off, int len)
+        {
+            if (data == null)
+                return 0;
+
+            int i = len;
+            int hc = i + 1;
+
+            while (--i >= 0)
+            {
+                ulong di = data[off + i];
+                hc *= 257;
+                hc ^= (int)di;
+                hc *= 257;
+                hc ^= (int)(di >> 32);
+            }
+
+            return hc;
+        }
+
         public static byte[] Clone(
             byte[] data)
         {