Class ByteUtils
java.lang.Object
io.getlime.security.powerauth.crypto.lib.util.ByteUtils
A utility class for handling byte array transformations.
- Author:
- Roman Strobl, roman.strobl@wultra.com
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]concat(byte[]... arrays) Concatenate multiple byte arrays.static byte[]concatStrings(String... strings) Concatenate multiple strings and convert them into a byte array, include each string length.static byte[]concatWithSizes(byte[]... arrays) Concatenate multiple byte arrays, including each component size.static byte[]encodeInt(int n) Encode an int number into a byte array.static byte[]encodeLong(long n) Encode a long number into a byte array.static byte[]encodeShort(short n) Encode a short number into a byte array.static byte[]Encode a String into a byte array.
-
Method Details
-
concat
public static byte[] concat(byte[]... arrays) Concatenate multiple byte arrays.- Parameters:
arrays- Byte arrays to concatenate.- Returns:
- Concatenated byte array.
-
concatWithSizes
public static byte[] concatWithSizes(byte[]... arrays) Concatenate multiple byte arrays, including each component size. Sample output byte array structure: [size1][array1][size2][array2] In case byte array is empty, each empty component is encoded as: [0]- Parameters:
arrays- Byte arrays to join.- Returns:
- Joined byte array.
-
concatStrings
Concatenate multiple strings and convert them into a byte array, include each string length.- Parameters:
strings- Strings to join.- Returns:
- Byte array with joined strings.
-
encodeShort
public static byte[] encodeShort(short n) Encode a short number into a byte array.- Parameters:
n- Short number to encode.- Returns:
- Byte array.
-
encodeInt
public static byte[] encodeInt(int n) Encode an int number into a byte array.- Parameters:
n- Int number to encode.- Returns:
- Byte array.
-
encodeLong
public static byte[] encodeLong(long n) Encode a long number into a byte array.- Parameters:
n- Long number to encode.- Returns:
- Byte array.
-
encodeString
Encode a String into a byte array.- Parameters:
s- String to encode.- Returns:
- Byte array.
-