Bouncy Castle Cryptography Library 1.77.0

org.bouncycastle.util
Class Arrays

java.lang.Object
  |
  +--org.bouncycastle.util.Arrays

public final class Arrays
extends java.lang.Object

General array utilities.


Inner Class Summary
static class Arrays.Iterator
          Iterator backed by a specific array.
 
Method Summary
static byte[] append(byte[] a, byte b)
           
static int[] append(int[] a, int b)
           
static short[] append(short[] a, short b)
           
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(java.lang.Object[] a, java.lang.Object[] b)
           
static boolean areEqual(short[] a, short[] b)
           
static void clear(byte[] data)
          Fill input array by zeros
static void clear(int[] data)
           
static java.math.BigInteger[] clone(java.math.BigInteger[] 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 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(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 java.math.BigInteger[] copyOf(java.math.BigInteger[] original, int newLength)
           
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[] copyOfRange(java.math.BigInteger[] original, int from, int to)
           
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 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(java.lang.Object[] a, int fromIndex, int toIndex, java.lang.Object val)
           
static void fill(java.lang.Object[] a, java.lang.Object val)
           
static void fill(short[] a, int fromIndex, int toIndex, short val)
           
static void fill(short[] a, short val)
           
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(java.lang.Object[] data)
           
static int hashCode(short[] data)
           
static int hashCode(short[][] shorts)
           
static int hashCode(short[][][] shorts)
           
static boolean isNullOrContainsNull(java.lang.Object[] array)
           
static boolean isNullOrEmpty(byte[] array)
           
static boolean isNullOrEmpty(int[] array)
           
static boolean isNullOrEmpty(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 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.
Parameters:
expected - first array
supplied - 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,
                        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

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,
                        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[] data)

hashCode

public static int hashCode(int[] data,
                           int off,
                           int len)

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 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)

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

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)

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)

hashCode

public static int hashCode(int[][] ints)

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)

Bouncy Castle Cryptography Library 1.77.0