Package com.nimbusds.jose.util
Class ByteUtils
- java.lang.Object
-
- com.nimbusds.jose.util.ByteUtils
-
-
Constructor Summary
Constructors Constructor Description ByteUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbitLength(byte[] byteArray)Returns the byte length of the specified byte array.static intbitLength(int byteLength)Returns the bit length of the specified byte length.static intbyteLength(int bitLength)Returns the byte length of the specified bit length.static byte[]concat(byte[]... byteArrays)Concatenates the specified byte arrays.static booleanisZeroFilled(byte[] byteArray)Returnstrueif the specified byte array is zero filled.static intsafeBitLength(byte[] byteArray)Returns the byte length of the specified byte array, preventing integer overflow.static intsafeBitLength(int byteLength)Returns the bit length of the specified byte length, preventing integer overflow.static byte[]subArray(byte[] byteArray, int beginIndex, int length)Returns a portion of the specified byte array.
-
-
-
Constructor Detail
-
ByteUtils
public ByteUtils()
-
-
Method Detail
-
concat
public static byte[] concat(byte[]... byteArrays)
Concatenates the specified byte arrays.- Parameters:
byteArrays- The byte arrays to concatenate, may benull.- Returns:
- The resulting byte array.
-
subArray
public static byte[] subArray(byte[] byteArray, int beginIndex, int length)
Returns a portion of the specified byte array.- Parameters:
byteArray- The byte array. Must not benull.beginIndex- The beginning index, inclusive. Must be zero or positive.length- The length. Must be zero or positive.- Returns:
- The byte array portion.
-
bitLength
public static int bitLength(int byteLength)
Returns the bit length of the specified byte length.- Parameters:
byteLength- The byte length.- Returns:
- The bit length.
-
safeBitLength
public static int safeBitLength(int byteLength) throws IntegerOverflowException
Returns the bit length of the specified byte length, preventing integer overflow.- Parameters:
byteLength- The byte length.- Returns:
- The bit length.
- Throws:
IntegerOverflowException- On a integer overflow.
-
bitLength
public static int bitLength(byte[] byteArray)
Returns the byte length of the specified byte array.- Parameters:
byteArray- The byte array. May benull.- Returns:
- The bite length, zero if the array is
null.
-
safeBitLength
public static int safeBitLength(byte[] byteArray) throws IntegerOverflowException
Returns the byte length of the specified byte array, preventing integer overflow.- Parameters:
byteArray- The byte array. May benull.- Returns:
- The bite length, zero if the array is
null. - Throws:
IntegerOverflowException- On a integer overflow.
-
byteLength
public static int byteLength(int bitLength)
Returns the byte length of the specified bit length.- Parameters:
bitLength- The bit length.- Returns:
- The byte byte length.
-
isZeroFilled
public static boolean isZeroFilled(byte[] byteArray)
Returnstrueif the specified byte array is zero filled.- Parameters:
byteArray- the byte array. Must not benull.- Returns:
trueif zero filled, elsefalse.
-
-