summary refs log tree commit diff
path: root/crypto/src/util/Arrays.cs
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2015-03-28 11:34:48 -0400
committerJeffrey Stedfast <jeff@xamarin.com>2015-03-28 11:34:48 -0400
commit393ff28f041de50a02acf45e9c0ba603a08e31b2 (patch)
tree4e48155cc30595686cf48631dff5f04f9cbfc2a8 /crypto/src/util/Arrays.cs
parentMerge branch 'master' into vs2010 (diff)
parentImproved docs and code cleanup (diff)
downloadBouncyCastle.NET-ed25519-393ff28f041de50a02acf45e9c0ba603a08e31b2.tar.xz
Merge branch 'master' into vs2010
Diffstat (limited to 'crypto/src/util/Arrays.cs')
-rw-r--r--crypto/src/util/Arrays.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs

index 8614baead..1f9711555 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) { @@ -613,5 +655,21 @@ namespace Org.BouncyCastle.Utilities return result; } + + public static int[] Reverse(int[] a) + { + if (a == null) + return null; + + int p1 = 0, p2 = a.Length; + int[] result = new int[p2]; + + while (--p2 >= 0) + { + result[p2] = a[p1++]; + } + + return result; + } } }