public static int charFromByteArray(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 0])) << 8; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 1])) << 0; return out; }
public static short shortFromByteArray(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 0])) << 8; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 1])) << 0; return (short) out; }
public static long longFromByteArrayLittleEndian(byte[] bytes, int offset) { long out = 0; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 7])) << 56; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 6])) << 48; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 5])) << 40; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 4])) << 32; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 3])) << 24; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 2])) << 16; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 1])) << 8; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 0])) << 0; return out; }
public static long longFromByteArray(byte[] bytes, int offset) { long out = 0; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 0])) << 56; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 1])) << 48; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 2])) << 40; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 3])) << 32; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 4])) << 24; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 5])) << 16; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 6])) << 8; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 7])) << 0; return out; }
static void addHexAscii(byte b, StringWriter sw) { short ub = toUnsigned(b); int h1 = ub / 16; int h2 = ub % 16; sw.write(toHexDigit(h1)); sw.write(toHexDigit(h2)); }
static void addHexAscii(byte b, StringWriter sw) { short ub = toUnsigned(b); int h1 = ub / 16; int h2 = ub % 16; sw.write(toHexDigit(h1)); sw.write(toHexDigit(h2)); }