Package org.bouncycastle.util
Class Arrays
- java.lang.Object
-
- org.bouncycastle.util.Arrays
-
public final class Arrays extends java.lang.ObjectGeneral array utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArrays.Iterator<T>Iterator backed by a specific array.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static byte[]append(byte[] a, byte b)static int[]append(int[] a, int b)static short[]append(short[] a, short b)static java.lang.String[]append(java.lang.String[] a, java.lang.String b)static booleanareAllZeroes(byte[] buf, int off, int len)static booleanareEqual(boolean[] a, boolean[] b)static booleanareEqual(byte[] a, byte[] b)static booleanareEqual(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)static booleanareEqual(char[] a, char[] b)static booleanareEqual(int[] a, int[] b)static booleanareEqual(long[] a, long[] b)static booleanareEqual(short[] a, short[] b)static booleanareEqual(java.lang.Object[] a, java.lang.Object[] b)static voidclear(byte[] data)Fill input array by zerosstatic voidclear(int[] data)static boolean[]clone(boolean[] data)static byte[]clone(byte[] data)static byte[][]clone(byte[][] data)static byte[][][]clone(byte[][][] data)static byte[]clone(byte[] data, byte[] existing)static char[]clone(char[] data)static int[]clone(int[] data)static long[]clone(long[] data)static long[]clone(long[] data, long[] existing)static short[]clone(short[] data)static java.math.BigInteger[]clone(java.math.BigInteger[] data)static intcompareUnsigned(byte[] a, byte[] b)static byte[]concatenate(byte[][] arrays)static byte[]concatenate(byte[] a, byte[] b)static byte[]concatenate(byte[] a, byte[] b, byte[] c)static byte[]concatenate(byte[] a, byte[] b, byte[] c, byte[] d)static int[]concatenate(int[] a, int[] b)static short[]concatenate(short[] a, short[] b)static booleanconstantTimeAreEqual(byte[] expected, byte[] supplied)A constant time equals comparison - does not terminate early if test will fail.static booleanconstantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)static booleancontains(boolean[] a, boolean val)static booleancontains(byte[] a, byte val)static booleancontains(char[] a, char val)static booleancontains(int[] a, int val)static booleancontains(long[] a, long val)static booleancontains(short[] a, short val)static boolean[]copyOf(boolean[] original, int newLength)static byte[]copyOf(byte[] original, int newLength)static char[]copyOf(char[] original, int newLength)static int[]copyOf(int[] original, int newLength)static long[]copyOf(long[] original, int newLength)static short[]copyOf(short[] original, int newLength)static java.math.BigInteger[]copyOf(java.math.BigInteger[] original, int newLength)static boolean[]copyOfRange(boolean[] original, int from, int to)static byte[]copyOfRange(byte[] original, int from, int to)Make a copy of a range of bytes from the passed in array.static char[]copyOfRange(char[] original, int from, int to)static int[]copyOfRange(int[] original, int from, int to)static long[]copyOfRange(long[] original, int from, int to)static short[]copyOfRange(short[] original, int from, int to)static java.math.BigInteger[]copyOfRange(java.math.BigInteger[] original, int from, int to)static voidfill(boolean[] a, boolean val)static voidfill(boolean[] a, int fromIndex, int toIndex, boolean val)static voidfill(byte[] a, byte val)static voidfill(byte[] a, int fromIndex, byte val)Deprecated.Usefill(byte[], int, int, byte)instead.static voidfill(byte[] a, int fromIndex, int toIndex, byte val)static voidfill(char[] a, char val)static voidfill(char[] a, int fromIndex, int toIndex, char val)static voidfill(int[] a, int val)static voidfill(int[] a, int fromIndex, int val)Deprecated.Usefill(int[], int, int, int)instead.static voidfill(int[] a, int fromIndex, int toIndex, int val)static voidfill(long[] a, int fromIndex, int toIndex, long val)static voidfill(long[] a, int fromIndex, long val)Deprecated.Usefill(long[], int, int, long)instead.static voidfill(long[] a, long val)static voidfill(short[] a, int fromIndex, int toIndex, short val)static voidfill(short[] a, int fromIndex, short val)Deprecated.Usefill(short[], int, int, short)instead.static voidfill(short[] a, short val)static voidfill(java.lang.Object[] a, int fromIndex, int toIndex, java.lang.Object val)static voidfill(java.lang.Object[] a, java.lang.Object val)static inthashCode(byte[] data)static inthashCode(byte[] data, int off, int len)static inthashCode(char[] data)static inthashCode(int[] data)static inthashCode(int[][] ints)static inthashCode(int[] data, int off, int len)static inthashCode(long[] data)static inthashCode(long[] data, int off, int len)static inthashCode(short[] data)static inthashCode(short[][] shorts)static inthashCode(short[][][] shorts)static inthashCode(java.lang.Object[] data)static booleanisNullOrContainsNull(java.lang.Object[] array)static booleanisNullOrEmpty(byte[] array)static booleanisNullOrEmpty(int[] array)static booleanisNullOrEmpty(java.lang.Object[] array)static byte[]prepend(byte[] a, byte b)static int[]prepend(int[] a, int b)static short[]prepend(short[] a, short b)static byte[]reverse(byte[] a)static int[]reverse(int[] a)
-
-
-
Method Detail
-
areAllZeroes
public static boolean areAllZeroes(byte[] buf, int off, int len)
-
areEqual
public static boolean areEqual(boolean[] a, boolean[] b)
-
areEqual
public static boolean areEqual(byte[] a, byte[] b)
-
areEqual
public static boolean areEqual(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)
-
areEqual
public static boolean areEqual(char[] a, char[] b)
-
areEqual
public static boolean areEqual(int[] a, int[] b)
-
areEqual
public static boolean areEqual(long[] a, long[] b)
-
areEqual
public static boolean areEqual(java.lang.Object[] a, java.lang.Object[] b)
-
areEqual
public static boolean areEqual(short[] a, short[] b)
-
constantTimeAreEqual
public static boolean constantTimeAreEqual(byte[] expected, byte[] supplied)A constant time equals comparison - does not terminate early if test will fail. For best results always pass the expected value as the first parameter.- Parameters:
expected- first arraysupplied- second array- Returns:
- true if arrays equal, false otherwise.
-
constantTimeAreEqual
public static boolean constantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)
-
compareUnsigned
public static int compareUnsigned(byte[] a, byte[] b)
-
contains
public static boolean contains(boolean[] a, boolean val)
-
contains
public static boolean contains(byte[] a, byte val)
-
contains
public static boolean contains(char[] a, char val)
-
contains
public static boolean contains(int[] a, int val)
-
contains
public static boolean contains(long[] a, long val)
-
contains
public static boolean contains(short[] a, short val)
-
fill
public static void fill(boolean[] a, boolean val)
-
fill
public static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)
-
fill
public static void fill(byte[] a, byte val)
-
fill
public static void fill(byte[] a, int fromIndex, byte val)Deprecated.Usefill(byte[], int, int, byte)instead.
-
fill
public static void fill(byte[] a, int fromIndex, int toIndex, byte val)
-
fill
public static void fill(char[] a, char val)
-
fill
public static void fill(char[] a, int fromIndex, int toIndex, char val)
-
fill
public static void fill(int[] a, int val)
-
fill
public static void fill(int[] a, int fromIndex, int val)Deprecated.Usefill(int[], int, int, int)instead.
-
fill
public static void fill(int[] a, int fromIndex, int toIndex, int val)
-
fill
public static void fill(long[] a, long val)
-
fill
public static void fill(long[] a, int fromIndex, long val)Deprecated.Usefill(long[], int, int, long)instead.
-
fill
public static void fill(long[] a, int fromIndex, int toIndex, long val)
-
fill
public static void fill(java.lang.Object[] a, java.lang.Object val)
-
fill
public static void fill(java.lang.Object[] a, int fromIndex, int toIndex, java.lang.Object val)
-
fill
public static void fill(short[] a, short val)
-
fill
public static void fill(short[] a, int fromIndex, short val)Deprecated.Usefill(short[], int, int, short)instead.
-
fill
public static void fill(short[] a, int fromIndex, int toIndex, short val)
-
hashCode
public static int hashCode(byte[] data)
-
hashCode
public static int hashCode(byte[] data, int off, int len)
-
hashCode
public static int hashCode(char[] data)
-
hashCode
public static int hashCode(int[][] ints)
-
hashCode
public static int hashCode(int[] data)
-
hashCode
public static int hashCode(int[] data, int off, int len)
-
hashCode
public static int hashCode(long[] data)
-
hashCode
public static int hashCode(long[] data, int off, int len)
-
hashCode
public static int hashCode(short[][][] shorts)
-
hashCode
public static int hashCode(short[][] shorts)
-
hashCode
public static int hashCode(short[] data)
-
hashCode
public static int hashCode(java.lang.Object[] data)
-
clone
public static boolean[] clone(boolean[] data)
-
clone
public static byte[] clone(byte[] data)
-
clone
public static char[] clone(char[] data)
-
clone
public static int[] clone(int[] data)
-
clone
public static long[] clone(long[] data)
-
clone
public static short[] clone(short[] data)
-
clone
public static java.math.BigInteger[] clone(java.math.BigInteger[] data)
-
clone
public static byte[] clone(byte[] data, byte[] existing)
-
clone
public static long[] clone(long[] data, long[] existing)
-
clone
public static byte[][] clone(byte[][] data)
-
clone
public static byte[][][] clone(byte[][][] data)
-
copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
-
copyOf
public static byte[] copyOf(byte[] original, int newLength)
-
copyOf
public static char[] copyOf(char[] original, int newLength)
-
copyOf
public static int[] copyOf(int[] original, int newLength)
-
copyOf
public static long[] copyOf(long[] original, int newLength)
-
copyOf
public static short[] copyOf(short[] original, int newLength)
-
copyOf
public static java.math.BigInteger[] copyOf(java.math.BigInteger[] original, int newLength)
-
copyOfRange
public static boolean[] copyOfRange(boolean[] original, int from, int to)
-
copyOfRange
public static byte[] copyOfRange(byte[] original, int from, int to)Make a copy of a range of bytes from the passed in array. The range can extend beyond the end of the input array, in which case the returned array will be padded with zeroes.- Parameters:
original- the array from which the data is to be copied.from- the start index at which the copying should take place.to- the final index of the range (exclusive).- Returns:
- a new byte array containing the range given.
-
copyOfRange
public static char[] copyOfRange(char[] original, int from, int to)
-
copyOfRange
public static int[] copyOfRange(int[] original, int from, int to)
-
copyOfRange
public static long[] copyOfRange(long[] original, int from, int to)
-
copyOfRange
public static short[] copyOfRange(short[] original, int from, int to)
-
copyOfRange
public static java.math.BigInteger[] copyOfRange(java.math.BigInteger[] original, int from, int to)
-
append
public static byte[] append(byte[] a, byte b)
-
append
public static short[] append(short[] a, short b)
-
append
public static int[] append(int[] a, int b)
-
append
public static java.lang.String[] append(java.lang.String[] a, java.lang.String b)
-
concatenate
public static byte[] concatenate(byte[] a, byte[] b)
-
concatenate
public static short[] concatenate(short[] a, short[] b)
-
concatenate
public static byte[] concatenate(byte[] a, byte[] b, byte[] c)
-
concatenate
public static byte[] concatenate(byte[] a, byte[] b, byte[] c, byte[] d)
-
concatenate
public static byte[] concatenate(byte[][] arrays)
-
concatenate
public static int[] concatenate(int[] a, int[] b)
-
prepend
public static byte[] prepend(byte[] a, byte b)
-
prepend
public static short[] prepend(short[] a, short b)
-
prepend
public static int[] prepend(int[] a, int b)
-
reverse
public static byte[] reverse(byte[] a)
-
reverse
public static int[] reverse(int[] a)
-
clear
public static void clear(byte[] data)
Fill input array by zeros- Parameters:
data- input array
-
clear
public static void clear(int[] data)
-
isNullOrContainsNull
public static boolean isNullOrContainsNull(java.lang.Object[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(byte[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(int[] array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.lang.Object[] array)
-
-