@Test public void encode() { assertEquals("yyyoryar", ZBase32.encode(new byte[]{0, 1, 2, 3, 4})); }
public static String encode(byte[] data) { if (data.length == 0) { return ""; } StringBuilder result = new StringBuilder(); int buffer = data[0]; int index = 1; int bitsLeft = 8; while (bitsLeft > 0 || index < data.length) { if (bitsLeft < SHIFT) { if (index < data.length) { buffer <<= 8; buffer |= (data[index++] & 0xff); bitsLeft += 8; } else { int pad = SHIFT - bitsLeft; buffer <<= pad; bitsLeft += pad; } } bitsLeft -= SHIFT; result.append(ALPHABET[MASK & (buffer >> bitsLeft)]); } return result.toString(); }
ZBase32 { public static String encode(byte[] data) { if (data.length == 0) { return ""; } StringBuilder result = new StringBuilder(); int buffer = data[0]; int index = 1; int bitsLeft = 8; while (bitsLeft > 0 || index < data.length) { if (bitsLeft < SHIFT) { if (index < data.length) { buffer <<= 8; buffer |= (data[index++] & 0xff); bitsLeft += 8; } else { int pad = SHIFT - bitsLeft; buffer <<= pad; bitsLeft += pad; } } bitsLeft -= SHIFT; result.append(ALPHABET[MASK & (buffer >> bitsLeft)]); } return result.toString(); } }
ZBase32 { public static String encode(byte[] data) { if (data.length == 0) { return ""; } StringBuilder result = new StringBuilder(); int buffer = data[0]; int index = 1; int bitsLeft = 8; while (bitsLeft > 0 || index < data.length) { if (bitsLeft < SHIFT) { if (index < data.length) { buffer <<= 8; buffer |= (data[index++] & 0xff); bitsLeft += 8; } else { int pad = SHIFT - bitsLeft; buffer <<= pad; bitsLeft += pad; } } bitsLeft -= SHIFT; result.append(ALPHABET[MASK & (buffer >> bitsLeft)]); } return result.toString(); } private  ZBase32(); }
ZBase32 { public static String encode(byte[] data) { if (data.length == 0) { return ""; } StringBuilder result = new StringBuilder(); int buffer = data[0]; int index = 1; int bitsLeft = 8; while (bitsLeft > 0 || index < data.length) { if (bitsLeft < SHIFT) { if (index < data.length) { buffer <<= 8; buffer |= (data[index++] & 0xff); bitsLeft += 8; } else { int pad = SHIFT - bitsLeft; buffer <<= pad; bitsLeft += pad; } } bitsLeft -= SHIFT; result.append(ALPHABET[MASK & (buffer >> bitsLeft)]); } return result.toString(); } private  ZBase32(); static String encode(byte[] data); }
ZBase32 { public static String encode(byte[] data) { if (data.length == 0) { return ""; } StringBuilder result = new StringBuilder(); int buffer = data[0]; int index = 1; int bitsLeft = 8; while (bitsLeft > 0 || index < data.length) { if (bitsLeft < SHIFT) { if (index < data.length) { buffer <<= 8; buffer |= (data[index++] & 0xff); bitsLeft += 8; } else { int pad = SHIFT - bitsLeft; buffer <<= pad; bitsLeft += pad; } } bitsLeft -= SHIFT; result.append(ALPHABET[MASK & (buffer >> bitsLeft)]); } return result.toString(); } private  ZBase32(); static String encode(byte[] data);  }