|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpaillierp.ByteUtils
public class ByteUtils
A set of static utilities for manipulating Bytes. The methods used in this class are used primarily for encoding integers and BigIntegers into byte arrays and vice versa.
Field Summary | |
---|---|
static java.lang.String[] |
base2
A string array for representing binary numbers. |
Constructor Summary | |
---|---|
ByteUtils()
|
Method Summary | |
---|---|
static byte[] |
appendBigInt(byte[] b,
java.math.BigInteger... bigIntegers)
Returns a byte array where the first bytes are b , followed
by each of bigIntegers in byte array form, each with its
length encoded in 4 bytes. |
static byte[] |
appendInt(byte[] b,
int... ints)
Returns a byte array where the first bytes are b , followed
by each of ints in 4-byte array form. |
static java.math.BigInteger |
getBigInt(byte[] b,
int offset,
int size)
Creates a BigInteger equivalent to the size bytes given in
b starting at offset. |
static int |
getInt(byte[] b,
int offset)
Determines the integer given in the first four bytes of a given array starting with the offset. |
static byte[] |
getLowerLayer(byte[] b)
Returns the first x bytes of b , where x is the
base 10 equivalent to the last four bytes of b . |
static byte[] |
intToByte(int i)
Converts an integer into its 4-byte equivalent in Big-endan form. |
static java.lang.String |
printByte(byte b)
Displays the given byte in a string of 0's and 1's. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String[] base2
Constructor Detail |
---|
public ByteUtils()
Method Detail |
---|
public static byte[] intToByte(int i)
i
- 32 bit integer
public static int getInt(byte[] b, int offset)
b
- Byte array of size greater than 4offset
- Index of b
public static java.math.BigInteger getBigInt(byte[] b, int offset, int size)
size
bytes given in
b
starting at offset.
b
- Byte arrayoffset
- Index of b; where to startsize
- how long to go
public static byte[] getLowerLayer(byte[] b)
b
, where x is the
base 10 equivalent to the last four bytes of b
.
b
- A byte array, the last four of which represent
an integer x
b
.public static byte[] appendBigInt(byte[] b, java.math.BigInteger... bigIntegers)
b
, followed
by each of bigIntegers
in byte array form, each with its
length encoded in 4 bytes.
b
- A byte arraybigIntegers
- BigIntegers i1, ...
im
b || len[
i1 ] ||
i1 || ... || len[
im ] ||
im. A byte array of length 0
is returned if (1) the concatenation would be too
large for an integer index or (2) b
is
of length 0.BigInteger.toByteArray()
public static byte[] appendInt(byte[] b, int... ints)
b
, followed
by each of ints
in 4-byte array form.
b
- A byte arrayints
- Integers i1, ...
im
b ||
i1 || ... ||
im. A byte array of length 0
is returned if (1) the concatenation would be too
large for an integer index or (2) b
is
of length 0.public static java.lang.String printByte(byte b)
b
- A simple byte
b
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |