public final class Bytes extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY |
static String |
INT_REQD_MSG |
static String |
LONG_REQD_MSG |
| Modifier and Type | Method and Description |
|---|---|
static long |
bitLength(byte[] bytes) |
static String |
bitsMsg(long bitLength) |
static String |
bytesMsg(int byteArrayLength) |
static void |
clear(byte[] bytes)
Clears the array by filling it with all zeros.
|
static byte[] |
concat(byte[]... arrays) |
static boolean |
endsWith(byte[] src,
byte[] suffix) |
static void |
increment(byte[] a) |
static int |
indexOf(byte[] source,
byte[] target) |
static int |
indexOf(byte[] source,
byte[] target,
int fromIndex) |
static boolean |
isEmpty(byte[] bytes) |
static int |
length(byte[] bytes) |
static int |
length(int bitLength)
Returns the minimum number of bytes required to represent the specified number of bits.
|
static byte[] |
nullSafe(byte[] bytes) |
static byte[] |
prepad(byte[] bytes,
int length)
Pads the front of the specified byte array with zeros if necessary, returning a new padded result, or the
original array unmodified if padding isn't necessary.
|
static byte[] |
random(int numBytes) |
static byte[] |
randomBits(int numBits) |
static boolean |
startsWith(byte[] src,
byte[] prefix) |
static boolean |
startsWith(byte[] src,
byte[] prefix,
int offset) |
static byte[] |
toBytes(int i) |
static byte[] |
toBytes(long l) |
static int |
toInt(byte[] bytes) |
static long |
toLong(byte[] bytes) |
public static final byte[] EMPTY
public static final String LONG_REQD_MSG
public static final String INT_REQD_MSG
public static byte[] nullSafe(byte[] bytes)
public static byte[] randomBits(int numBits)
public static byte[] random(int numBytes)
public static byte[] toBytes(int i)
public static byte[] toBytes(long l)
public static long toLong(byte[] bytes)
public static int toInt(byte[] bytes)
public static int indexOf(byte[] source,
byte[] target)
public static int indexOf(byte[] source,
byte[] target,
int fromIndex)
public static boolean startsWith(byte[] src,
byte[] prefix)
public static boolean startsWith(byte[] src,
byte[] prefix,
int offset)
public static boolean endsWith(byte[] src,
byte[] suffix)
public static byte[] concat(byte[]... arrays)
public static void clear(byte[] bytes)
bytes - the (possibly null or empty) byte array to clearpublic static boolean isEmpty(byte[] bytes)
public static int length(byte[] bytes)
public static long bitLength(byte[] bytes)
public static int length(int bitLength)
This is defined/used by many specifications, such as:
Base64urlUInt definitionInteger-to-OctetString conversion defined by Section 2.3.7 of the
Standards for Efficient Cryptography Group,
&qupt;SEC 1: Elliptic Curve Cryptography" Version 2.0, May 2009 (as required by
RFC 7518, Section 3.4)bitLength - the number of bits to represent as a byte array, must be >= 0IllegalArgumentException - if bitLength is less than zero.public static String bitsMsg(long bitLength)
public static String bytesMsg(int byteArrayLength)
public static void increment(byte[] a)
public static byte[] prepad(byte[] bytes,
int length)
length is greater
than bytes.length.bytes - the byte array to pre-pad with zeros if necessarylength - the length of the required output arraybytes array if padding wasn't necessary.Copyright © 2014–2024 jsonwebtoken.io. All rights reserved.