summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/Arrays.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index cc2025ef3..a21dd00b1 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -220,6 +220,25 @@ namespace Org.BouncyCastle.Utilities
             return hc;
         }
 
+        public static int GetHashCode(byte[] data, int off, int len)
+        {
+            if (data == null)
+            {
+                return 0;
+            }
+
+            int i = len;
+            int hc = i + 1;
+
+            while (--i >= 0)
+            {
+                hc *= 257;
+                hc ^= data[off + i];
+            }
+
+            return hc;
+        }
+
         public static int GetHashCode(int[] data)
         {
             if (data == null)
@@ -237,6 +256,23 @@ namespace Org.BouncyCastle.Utilities
             return hc;
         }
 
+        public static int GetHashCode(int[] data, int off, int len)
+        {
+            if (data == null)
+                return 0;
+
+            int i = len;
+            int hc = i + 1;
+
+            while (--i >= 0)
+            {
+                hc *= 257;
+                hc ^= data[off + i];
+            }
+
+            return hc;
+        }
+
         [CLSCompliantAttribute(false)]
         public static int GetHashCode(uint[] data)
         {
@@ -255,6 +291,24 @@ namespace Org.BouncyCastle.Utilities
             return hc;
         }
 
+        [CLSCompliantAttribute(false)]
+        public static int GetHashCode(uint[] data, int off, int len)
+        {
+            if (data == null)
+                return 0;
+
+            int i = len;
+            int hc = i + 1;
+
+            while (--i >= 0)
+            {
+                hc *= 257;
+                hc ^= (int)data[off + i];
+            }
+
+            return hc;
+        }
+
         public static byte[] Clone(
             byte[] data)
         {