Base32 { public static long decodeBase32(String hash) { boolean isNegative = hash.startsWith("-"); int startIndex = isNegative ? 1 : 0; long base = 1; long result = 0; for (int i = hash.length() - 1; i >= startIndex; i--) { int j = getCharIndex(hash.charAt(i)); result = result + base * j; base = base * 32; } if (isNegative) result *= -1; return result; } private  Base32(); static String encodeBase32(long i, int length); static String encodeBase32(long i); static long decodeBase32(String hash);  }
@Test public void testDecodeToPositiveInteger() { assertEquals(1234567, decodeBase32("15pn7")); }
@Test public void testDecodeManyZeros() { assertEquals(0, decodeBase32("0000000")); }
@Test public void testDecodeOneZero() { assertEquals(0, decodeBase32("0")); }