class 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();
	}

}