public class ByteUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
bigIntToByteArrayLeadingZeros(java.math.BigInteger value,
int numBytes)
Converts a BigInteger to a byte array of the given size leading with zeros.
|
static byte[] |
bigIntToBytes(java.math.BigInteger x)
Converts a BigInteger value into an array of 8 bytes.
|
static byte[] |
byteArrayLeadingZeros(byte[] valueByteArray,
int numBytes)
It completes the byte array to a byte array of the given size leading with zeros.
|
static int |
bytesToInt(byte[] bytes)
Converts an array of 4 bytes into a int.
|
static byte[] |
intToBytes(int x)
Converts an int value into an array of 4 bytes.
|
static int |
isEqualConstantTime(int b,
int c)
Constant-time byte comparison.
|
static int |
isNegativeConstantTime(int b)
Constant-time check if byte is negative.
|
static byte[] |
longToBytes(long x)
Converts a long value into an array of 8 bytes.
|
static byte[] |
shortToBytes(short x)
Converts an short value into an array of 4 bytes.
|
static java.lang.String |
toString(byte[] bytes)
Creates a human readable representation of an array of bytes.
|
public static byte[] bigIntToByteArrayLeadingZeros(java.math.BigInteger value, int numBytes)
value
- The value to convert.numBytes
- The number of bytes in the destination array.public static byte[] byteArrayLeadingZeros(byte[] valueByteArray, int numBytes)
valueByteArray
- the source byte array.numBytes
- The number of bytes in the destination array.public static byte[] bigIntToBytes(java.math.BigInteger x)
x
- The BigInteger.public static byte[] longToBytes(long x)
x
- The long.public static int bytesToInt(byte[] bytes)
bytes
- The bytes.public static byte[] intToBytes(int x)
x
- The int.public static byte[] shortToBytes(short x)
x
- The short.public static int isEqualConstantTime(int b, int c)
b
- One byte.c
- Another byte.public static int isNegativeConstantTime(int b)
b
- The byte to check.public static java.lang.String toString(byte[] bytes)
bytes
- The bytes.