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.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index 57d79c0bb..784d45efb 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -804,6 +804,38 @@ namespace Org.BouncyCastle.Utilities
             return result;
         }
 
+        public static byte[] ReverseInPlace(byte[] a)
+        {
+            if (null == a)
+                return null;
+
+            int p1 = 0, p2 = a.Length - 1;
+            while (p1 < p2)
+            {
+                byte t1 = a[p1], t2 = a[p2];
+                a[p1++] = t2;
+                a[p2--] = t1;
+            }
+
+            return a;
+        }
+
+        public static int[] ReverseInPlace(int[] a)
+        {
+            if (null == a)
+                return null;
+
+            int p1 = 0, p2 = a.Length - 1;
+            while (p1 < p2)
+            {
+                int t1 = a[p1], t2 = a[p2];
+                a[p1++] = t2;
+                a[p2--] = t1;
+            }
+
+            return a;
+        }
+
         public static void Clear(byte[] data)
         {
             if (null != data)