Package org.bouncycastle.util
Class Arrays
java.lang.Object
org.bouncycastle.util.Arrays
General array utilities.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Iterator backed by a specific array. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
append
(byte[] a, byte b) static int[]
append
(int[] a, int b) static short[]
append
(short[] a, short b) static String[]
static boolean
areAllZeroes
(byte[] buf, int off, int len) static boolean
areEqual
(boolean[] a, boolean[] b) static boolean
areEqual
(byte[] a, byte[] b) static boolean
areEqual
(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex) static boolean
areEqual
(char[] a, char[] b) static boolean
areEqual
(int[] a, int[] b) static boolean
areEqual
(long[] a, long[] b) static boolean
areEqual
(short[] a, short[] b) static boolean
static void
clear
(byte[] data) Fill input array by zerosstatic void
clear
(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 BigInteger[]
clone
(BigInteger[] data) static int
compareUnsigned
(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 boolean
constantTimeAreEqual
(byte[] expected, byte[] supplied) A constant time equals comparison - does not terminate early if test will fail.static boolean
constantTimeAreEqual
(char[] expected, char[] supplied) A constant time equals comparison - does not terminate early if comparison fails.static boolean
constantTimeAreEqual
(int len, byte[] a, int aOff, byte[] b, int bOff) static boolean
contains
(boolean[] a, boolean val) static boolean
contains
(byte[] a, byte val) static boolean
contains
(char[] a, char val) static boolean
contains
(int[] a, int val) static boolean
contains
(long[] a, long val) static boolean
contains
(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 BigInteger[]
copyOf
(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 BigInteger[]
copyOfRange
(BigInteger[] original, int from, int to) static void
fill
(boolean[] a, boolean val) static void
fill
(boolean[] a, int fromIndex, int toIndex, boolean val) static void
fill
(byte[] a, byte val) static void
fill
(byte[] a, int fromIndex, int toIndex, byte val) static void
fill
(char[] a, char val) static void
fill
(char[] a, int fromIndex, int toIndex, char val) static void
fill
(int[] a, int val) static void
fill
(int[] a, int fromIndex, int toIndex, int val) static void
fill
(long[] a, int fromIndex, int toIndex, long val) static void
fill
(long[] a, long val) static void
fill
(short[] a, int fromIndex, int toIndex, short val) static void
fill
(short[] a, short val) static void
static void
static int
hashCode
(byte[] data) static int
hashCode
(byte[] data, int off, int len) static int
hashCode
(char[] data) static int
hashCode
(int[] data) static int
hashCode
(int[][] ints) static int
hashCode
(int[] data, int off, int len) static int
hashCode
(long[] data) static int
hashCode
(long[] data, int off, int len) static int
hashCode
(short[] data) static int
hashCode
(short[][] shorts) static int
hashCode
(short[][][] shorts) static int
static boolean
isNullOrContainsNull
(Object[] array) static boolean
isNullOrEmpty
(byte[] array) static boolean
isNullOrEmpty
(int[] array) static boolean
isNullOrEmpty
(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 void
reverse
(byte[] input, byte[] output) static int[]
reverse
(int[] a) static byte[]
reverseInPlace
(byte[] a) static void
reverseInPlace
(byte[] a, int aOff, int aLen) static int[]
reverseInPlace
(int[] a) static short[]
reverseInPlace
(short[] a)
-
Method Details
-
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
-
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) -
constantTimeAreEqual
public static boolean constantTimeAreEqual(char[] expected, char[] supplied) A constant time equals comparison - does not terminate early if comparison fails. 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.
-
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, 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 toIndex, int val) -
fill
public static void fill(long[] a, long val) -
fill
public static void fill(long[] a, int fromIndex, int toIndex, long val) -
fill
-
fill
-
fill
public static void fill(short[] a, short val) -
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
-
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
-
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
-
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
-
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
-
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) -
reverse
public static void reverse(byte[] input, byte[] output) -
reverseInPlace
public static byte[] reverseInPlace(byte[] a) -
reverseInPlace
public static void reverseInPlace(byte[] a, int aOff, int aLen) -
reverseInPlace
public static short[] reverseInPlace(short[] a) -
reverseInPlace
public static int[] reverseInPlace(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
-
isNullOrEmpty
public static boolean isNullOrEmpty(byte[] array) -
isNullOrEmpty
public static boolean isNullOrEmpty(int[] array) -
isNullOrEmpty
-