Class ByteUtils
java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.ByteUtils
Deprecated.
use org.bouncycastle.util.Arrays.
This class is a utility class for manipulating byte arrays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
clone
(byte[] array) Deprecated.Return a clone of the given byte array (performs null check beforehand).static byte[]
concatenate
(byte[][] array) Deprecated.Convert a 2-dimensional byte array into a 1-dimensional byte array by concatenating all entries.static byte[]
concatenate
(byte[] x1, byte[] x2) Deprecated.Concatenate two byte arrays.static int
deepHashCode
(byte[] array) Deprecated.Computes a hashcode based on the contents of a one-dimensional byte array rather than its identity.static int
deepHashCode
(byte[][] array) Deprecated.Computes a hashcode based on the contents of a two-dimensional byte array rather than its identity.static int
deepHashCode
(byte[][][] array) Deprecated.Computes a hashcode based on the contents of a three-dimensional byte array rather than its identity.static boolean
equals
(byte[][][] left, byte[][][] right) Deprecated.Compare two three-dimensional byte arrays.static boolean
equals
(byte[][] left, byte[][] right) Deprecated.Compare two two-dimensional byte arrays.static boolean
equals
(byte[] left, byte[] right) Deprecated.Compare two byte arrays (perform null checks beforehand).static byte[]
Deprecated.Convert a string containing hexadecimal characters to a byte-array.static byte[][]
split
(byte[] input, int index) Deprecated.Split a byte array input into two arrays at index, i.e.static byte[]
subArray
(byte[] input, int start) Deprecated.Generate a subarray of a given byte array.static byte[]
subArray
(byte[] input, int start, int end) Deprecated.Generate a subarray of a given byte array.static String
toBinaryString
(byte[] input) Deprecated.Convert a byte array to the corresponding bit string.static char[]
toCharArray
(byte[] input) Deprecated.Rewrite a byte array as a char arraystatic String
toHexString
(byte[] input) Deprecated.Convert a byte array to the corresponding hexstring.static String
toHexString
(byte[] input, String prefix, String seperator) Deprecated.Convert a byte array to the corresponding hex string.static byte[]
xor
(byte[] x1, byte[] x2) Deprecated.Compute the bitwise XOR of two arrays of bytes.
-
Method Details
-
equals
public static boolean equals(byte[] left, byte[] right) Deprecated.Compare two byte arrays (perform null checks beforehand).- Parameters:
left
- the first byte arrayright
- the second byte array- Returns:
- the result of the comparison
-
equals
public static boolean equals(byte[][] left, byte[][] right) Deprecated.Compare two two-dimensional byte arrays. No null checks are performed.- Parameters:
left
- the first byte arrayright
- the second byte array- Returns:
- the result of the comparison
-
equals
public static boolean equals(byte[][][] left, byte[][][] right) Deprecated.Compare two three-dimensional byte arrays. No null checks are performed.- Parameters:
left
- the first byte arrayright
- the second byte array- Returns:
- the result of the comparison
-
deepHashCode
public static int deepHashCode(byte[] array) Deprecated.Computes a hashcode based on the contents of a one-dimensional byte array rather than its identity.- Parameters:
array
- the array to compute the hashcode of- Returns:
- the hashcode
-
deepHashCode
public static int deepHashCode(byte[][] array) Deprecated.Computes a hashcode based on the contents of a two-dimensional byte array rather than its identity.- Parameters:
array
- the array to compute the hashcode of- Returns:
- the hashcode
-
deepHashCode
public static int deepHashCode(byte[][][] array) Deprecated.Computes a hashcode based on the contents of a three-dimensional byte array rather than its identity.- Parameters:
array
- the array to compute the hashcode of- Returns:
- the hashcode
-
clone
public static byte[] clone(byte[] array) Deprecated.Return a clone of the given byte array (performs null check beforehand).- Parameters:
array
- the array to clone- Returns:
- the clone of the given array, or null if the array is null
-
fromHexString
Deprecated.Convert a string containing hexadecimal characters to a byte-array.- Parameters:
s
- a hex string- Returns:
- a byte array with the corresponding value
-
toHexString
Deprecated.Convert a byte array to the corresponding hexstring.- Parameters:
input
- the byte array to be converted- Returns:
- the corresponding hexstring
-
toHexString
Deprecated.Convert a byte array to the corresponding hex string.- Parameters:
input
- the byte array to be convertedprefix
- the prefix to put at the beginning of the hex stringseperator
- a separator string- Returns:
- the corresponding hex string
-
toBinaryString
Deprecated.Convert a byte array to the corresponding bit string.- Parameters:
input
- the byte array to be converted- Returns:
- the corresponding bit string
-
xor
public static byte[] xor(byte[] x1, byte[] x2) Deprecated.Compute the bitwise XOR of two arrays of bytes. The arrays have to be of same length. No length checking is performed.- Parameters:
x1
- the first arrayx2
- the second array- Returns:
- x1 XOR x2
-
concatenate
public static byte[] concatenate(byte[] x1, byte[] x2) Deprecated.Concatenate two byte arrays. No null checks are performed.- Parameters:
x1
- the first arrayx2
- the second array- Returns:
- (x2 | | x1) (little-endian order, i.e. x1 is at lower memory addresses)
-
concatenate
public static byte[] concatenate(byte[][] array) Deprecated.Convert a 2-dimensional byte array into a 1-dimensional byte array by concatenating all entries.- Parameters:
array
- a 2-dimensional byte array- Returns:
- the concatenated input array
-
split
Deprecated.Split a byte array input into two arrays at index, i.e. the first array will have the lower index bytes, the second one the higher input.length - index bytes.- Parameters:
input
- the byte array to be splitindex
- the index where the byte array is split- Returns:
- the splitted input array as an array of two byte arrays
- Throws:
ArrayIndexOutOfBoundsException
- if index is out of bounds
-
subArray
public static byte[] subArray(byte[] input, int start, int end) Deprecated.Generate a subarray of a given byte array.- Parameters:
input
- the input byte arraystart
- the start indexend
- the end index- Returns:
- a subarray of input, ranging from start (inclusively) to end (exclusively)
-
subArray
public static byte[] subArray(byte[] input, int start) Deprecated.Generate a subarray of a given byte array.- Parameters:
input
- the input byte arraystart
- the start index- Returns:
- a subarray of input, ranging from start to the end of the array
-
toCharArray
public static char[] toCharArray(byte[] input) Deprecated.Rewrite a byte array as a char array- Parameters:
input
- - the byte array- Returns:
- char array
-