ShortUUID { public static String encode(String longUUID) { String uuidStr = longUUID.toString().replaceAll("-", ""); Double factor = Math.log(25d) / Math.log(ALPHABET_LEN); Double length = Math.ceil(factor * 16); BigInteger number = new BigInteger(uuidStr, 16); return encode(number, ALPHABET, length.intValue()); }  static String randomUUID(); static String encode(String longUUID); static String decode(String shortUUID);  }
@Test public void testEncoding() { String[][] tests = getTests(); for (String[] test : tests) { assertEquals(test[1], ShortUUID.encode(test[0])); } }