@Test public void testCompactHexEncode_2() { byte[] test = "verb".getBytes(); byte[] result = new byte[]{7, 6, 6, 5, 7, 2, 6, 2, T}; assertArrayEquals(result, CompactEncoder.binToNibbles(test)); }
public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1); for (int i = 0; i < hexEncoded.length; ++i){ byte b = hexEncodedTerminated[i]; hexEncodedTerminated[i] = hexMap.get((char) b); } hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR; return hexEncodedTerminated; }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1); for (int i = 0; i < hexEncoded.length; ++i){ byte b = hexEncodedTerminated[i]; hexEncodedTerminated[i] = hexMap.get((char) b); } hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR; return hexEncodedTerminated; } }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1); for (int i = 0; i < hexEncoded.length; ++i){ byte b = hexEncodedTerminated[i]; hexEncodedTerminated[i] = hexMap.get((char) b); } hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR; return hexEncodedTerminated; }  }
CompactEncoder { public static byte[] binToNibbles(byte[] str) { byte[] hexEncoded = encode(str); byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1); for (int i = 0; i < hexEncoded.length; ++i){ byte b = hexEncodedTerminated[i]; hexEncodedTerminated[i] = hexMap.get((char) b); } hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR; return hexEncodedTerminated; }  static byte[] packNibbles(byte[] nibbles); static boolean hasTerminator(byte[] packedKey); 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); byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1); for (int i = 0; i < hexEncoded.length; ++i){ byte b = hexEncodedTerminated[i]; hexEncodedTerminated[i] = hexMap.get((char) b); } hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR; return hexEncodedTerminated; }  static byte[] packNibbles(byte[] nibbles); static boolean hasTerminator(byte[] packedKey); static byte[] unpackToNibbles(byte[] str); static byte[] binToNibbles(byte[] str); static byte[] binToNibblesNoTerminator(byte[] str);  }