@Test public void testCompactHexEncode_1() { byte[] test = "stallion".getBytes(); byte[] result = new byte[] { 7, 3, 7, 4, 6, 1, 6, 12, 6, 12, 6, 9, 6, 15, 6, 14, T }; assertArrayEquals(result, CompactEncoder.binToNibbles(test)); }
public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); ByteBuffer slice = ByteBuffer.allocate(hexEncoded.length + 1); for (byte b : hexEncoded) { slice.put(hexMap.get((char)b)); } slice.put(TERMINATOR); return slice.array(); }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); ByteBuffer slice = ByteBuffer.allocate(hexEncoded.length + 1); for (byte b : hexEncoded) { slice.put(hexMap.get((char)b)); } slice.put(TERMINATOR); return slice.array(); } }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); ByteBuffer slice = ByteBuffer.allocate(hexEncoded.length + 1); for (byte b : hexEncoded) { slice.put(hexMap.get((char)b)); } slice.put(TERMINATOR); return slice.array(); }  }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); ByteBuffer slice = ByteBuffer.allocate(hexEncoded.length + 1); for (byte b : hexEncoded) { slice.put(hexMap.get((char)b)); } slice.put(TERMINATOR); return slice.array(); }  static byte[] packNibbles(byte[] nibbles); static byte[] unpackToNibbles(byte[] str); static byte[] binToNibbles(byte[] str); static byte[] binToNibblesNoTerminator(byte[] str); }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); ByteBuffer slice = ByteBuffer.allocate(hexEncoded.length + 1); for (byte b : hexEncoded) { slice.put(hexMap.get((char)b)); } slice.put(TERMINATOR); return slice.array(); }  static byte[] packNibbles(byte[] nibbles); static byte[] unpackToNibbles(byte[] str); static byte[] binToNibbles(byte[] str); static byte[] binToNibblesNoTerminator(byte[] str);  }