Package com.yubico.internal.util
Class BinaryUtil
java.lang.Object
com.yubico.internal.util.BinaryUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]copy(byte[] bytes) static byte[]encodeUint16(int value) static byte[]encodeUint32(long value) static byte[]static intgetUint16(byte[] bytes) Read 2 bytes as a big endian unsigned 16-bit integer.static longgetUint32(byte[] bytes) Read 4 bytes as a big endian unsigned 32-bit integer.static shortgetUint8(byte b) Read one byte as an unsigned 8-bit integer.static byte[]readAll(InputStream is) static bytesingleFromHex(String hex) Parse a single byte from two hexadecimal characters.static StringtoHex(byte[] bytes)
-
Constructor Details
-
BinaryUtil
public BinaryUtil()
-
-
Method Details
-
copy
public static byte[] copy(byte[] bytes) -
toHex
- Parameters:
bytes- Bytes to encode
-
fromHex
- Parameters:
hex- String of hexadecimal digits to decode as bytes.
-
singleFromHex
Parse a single byte from two hexadecimal characters.- Parameters:
hex- String of hexadecimal digits to decode as bytes.
-
getUint8
public static short getUint8(byte b) Read one byte as an unsigned 8-bit integer.Result is of type
shortbecause Java doesn't have unsigned types.- Returns:
- A value between 0 and 255, inclusive.
-
getUint16
public static int getUint16(byte[] bytes) Read 2 bytes as a big endian unsigned 16-bit integer.Result is of type
intbecause Java doesn't have unsigned types.- Returns:
- A value between 0 and 2^16- 1, inclusive.
-
getUint32
public static long getUint32(byte[] bytes) Read 4 bytes as a big endian unsigned 32-bit integer.Result is of type
longbecause Java doesn't have unsigned types.- Returns:
- A value between 0 and 2^32 - 1, inclusive.
-
encodeUint16
public static byte[] encodeUint16(int value) -
encodeUint32
public static byte[] encodeUint32(long value) -
readAll
- Throws:
IOException
-