public class ByteConversionUtil extends Object
CipherTextSerializer
Constructor and Description |
---|
ByteConversionUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
fromInt(int input)
Returns a byte array containing 4 network byte-ordered bytes representing the
given
int . |
static byte[] |
fromLong(long input)
Returns a byte array containing 8 network byte-ordered bytes representing
the given
long . |
static byte[] |
fromShort(short input)
Returns a byte array containing 2 network byte ordered bytes representing
the given
short . |
static int |
toInt(byte[] input)
Converts a given byte array to an
int . |
static long |
toLong(byte[] input)
Converts a given byte array to a
long . |
static short |
toShort(byte[] input)
Converts a given byte array to an
short . |
public static byte[] fromShort(short input)
short
.input
- An short
to convert to a byte array.short
in network byte
order (i.e., big-endian order).public static byte[] fromInt(int input)
int
.input
- An int
to convert to a byte array.int
in network byte order
(i.e., big-endian order).public static byte[] fromLong(long input)
long
.input
- The long
to convert to a byte
array.long
.public static short toShort(byte[] input)
short
. Bytes are expected in
network byte order.input
- A network byte-ordered representation of an short
,
so exactly 2 bytes are expected.short
value represented by the input array.public static int toInt(byte[] input)
int
. Bytes are expected in
network byte order.input
- A network byte-ordered representation of an int
.
Must be exactly 4 bytes.int
value represented by the input array.public static long toLong(byte[] input)
long
. Bytes are expected in
network byteinput
- A network byte-ordered representation of a long
.
Must be exactly 8 bytes.long
value represented by the input arrayCopyright © 2020 The Open Web Application Security Project (OWASP). All rights reserved.