Package com.nimbusds.jose.util
Class ByteUtils
java.lang.Object
com.nimbusds.jose.util.ByteUtils
Byte utilities.
- Version:
- 2022-04-22
- Author:
- Vladimir Dzhuvinov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
bitLength
(byte[] byteArray) Returns the byte length of the specified byte array.static int
bitLength
(int byteLength) Returns the bit length of the specified byte length.static int
byteLength
(int bitLength) Returns the byte length of the specified bit length.static byte[]
concat
(byte[]... byteArrays) Concatenates the specified byte arrays.static boolean
isZeroFilled
(byte[] byteArray) Returnstrue
if the specified byte array is zero filled.static int
safeBitLength
(byte[] byteArray) Returns the byte length of the specified byte array, preventing integer overflow.static int
safeBitLength
(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 Details
-
ByteUtils
public ByteUtils()
-
-
Method Details
-
concat
Concatenates the specified byte arrays.- Parameters:
byteArrays
- The byte arrays to concatenate, may benull
.- Returns:
- The resulting byte array.
-
subArray
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
Returns the bit length of the specified byte length.- Parameters:
byteLength
- The byte length.- Returns:
- The bit length.
-
safeBitLength
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
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
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
Returns the byte length of the specified bit length.- Parameters:
bitLength
- The bit length.- Returns:
- The byte byte length.
-
isZeroFilled
Returnstrue
if the specified byte array is zero filled.- Parameters:
byteArray
- the byte array. Must not benull
.- Returns:
true
if zero filled, elsefalse
.
-