Methods Summary |
---|
public static void | checkBounds(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)Verifies that method parameters are correct.
NOTE: This method accepts too big outputOffset values - cipher
methods must throw ShortBufferException if there are output data.
if (inputLen != 0 && (input == null || inputOffset < 0 ||
inputLen < 0 || inputOffset + inputLen > input.length)) {
throw new IllegalArgumentException("input out of bounds");
}
if (output == null || outputOffset < 0) {
throw new IllegalArgumentException("output out of bounds");
}
|
public static byte[] | cloneArray(byte[] array)Creates a copy of byte array.
byte[] data = new byte[array.length];
System.arraycopy(array, 0, data, 0, array.length);
return data;
|
public static byte[] | cloneSubarray(byte[] array, int offset, int len)Creates a copy of byte array.
byte[] data = new byte[len];
System.arraycopy(array, 0, data, offset, len);
return data;
|
public static int | getInt(byte[] data, int offset)Returns 4 bytes from the buffer as integer value.
int res = 0;
for (int i = 0; i < 4; i++) {
res = (res << 8) | (data[offset + i] & 0xff);
}
return res;
|
static java.lang.String | hexEncode(byte[] b)Converts a byte array into a corresponding string of hexadecimal
digits. This is equivalent to hexEncode(b, 0, b.length).
if (b == null)
return ("");
else {
char[] r = new char[b.length << 1];
int v;
for (int i = 0, j = 0; i < b.length; i++) {
v = b[i] & 0xff;
r[j++] = hc[v >>> 4];
r[j++] = hc[v & 0x0f];
}
return (new String(r));
}
|
public static byte[] | unpackBytes(java.lang.String src)Unpacks data from string representation.
byte[] data = src.getBytes();
int srcLen, len;
byte[] res = new byte[len =
((srcLen = data.length) >> 3) * 7 + (srcLen & 7) - 1];
int i = 0;
for (int k = len; k < srcLen; k++) {
int mask = data[k];
for (int j = 0; j < 7 && i < len; j++, i++) {
res[i] = ((mask & (1 << j)) == 0) ? data[i] :
(byte) (data[i] | 0x80);
}
}
return res;
|
public static void | xorArrays(byte[] a, byte[] b)Performs an XOR operation of arrays elements. Results are placed
into the first array.
for (int i = 0; i < a.length; i++) {
a[i] ^= b[i];
}
|