@Test public void shouldDecodeBase45Correctly() { assertEquals(1, decodeBase45("#")); assertEquals(2, decodeBase45("$")); assertEquals(1, decodeBase45("R")); assertEquals(2, decodeBase45("S")); assertEquals(44, decodeBase45("P")); assertEquals(44, decodeBase45("~")); assertEquals(45, decodeBase45("#!")); assertEquals(45, decodeBase45("RQ")); assertEquals(1, decodeBase45("!R")); assertEquals(2, decodeBase45("!S")); assertEquals(1, decodeBase45("Q#")); assertEquals(2, decodeBase45("Q$")); assertEquals(44, decodeBase45("!~")); assertEquals(44, decodeBase45("QP")); assertEquals(45, decodeBase45("#Q")); assertEquals(45, decodeBase45("R!")); assertEquals(2025, decodeBase45("RQ!")); assertEquals(2025, decodeBase45("RQQ")); assertEquals(2025, decodeBase45("#!Q")); assertEquals(2025, decodeBase45("#!!")); assertEquals(2024, decodeBase45("~P")); assertEquals(2024, decodeBase45("~~")); assertEquals(2024, decodeBase45("P~")); assertEquals(2024, decodeBase45("PP")); assertEquals(12345, decodeBase45("WU2")); }
public static long decodeBase45(CharSequence charSequence) { long sum = 0; for (int i = 0; i < charSequence.length(); i++) { final int c = (int) charSequence.charAt(i); int add = decodeChar(c); if (add >= BASE45) { add -= BASE45; } sum = (sum * (long) BASE45) + (long) add; } return sum; }
CookieSafeBase90 { public static long decodeBase45(CharSequence charSequence) { long sum = 0; for (int i = 0; i < charSequence.length(); i++) { final int c = (int) charSequence.charAt(i); int add = decodeChar(c); if (add >= BASE45) { add -= BASE45; } sum = (sum * (long) BASE45) + (long) add; } return sum; } }
CookieSafeBase90 { public static long decodeBase45(CharSequence charSequence) { long sum = 0; for (int i = 0; i < charSequence.length(); i++) { final int c = (int) charSequence.charAt(i); int add = decodeChar(c); if (add >= BASE45) { add -= BASE45; } sum = (sum * (long) BASE45) + (long) add; } return sum; }  }
CookieSafeBase90 { public static long decodeBase45(CharSequence charSequence) { long sum = 0; for (int i = 0; i < charSequence.length(); i++) { final int c = (int) charSequence.charAt(i); int add = decodeChar(c); if (add >= BASE45) { add -= BASE45; } sum = (sum * (long) BASE45) + (long) add; } return sum; }  static String encodeBase45(long value, boolean highRange, boolean flipLastByte); static String encodeBase90Unsigned(long value); static String encodeBase90Signed(long value); static String encodeBytesBase90(byte[] bytes); static byte[] decodeBytesBase90(CharSequence charSequence); static long decodeBase90(CharSequence charSequence, boolean signed); static long decodeBase45(CharSequence charSequence); }
CookieSafeBase90 { public static long decodeBase45(CharSequence charSequence) { long sum = 0; for (int i = 0; i < charSequence.length(); i++) { final int c = (int) charSequence.charAt(i); int add = decodeChar(c); if (add >= BASE45) { add -= BASE45; } sum = (sum * (long) BASE45) + (long) add; } return sum; }  static String encodeBase45(long value, boolean highRange, boolean flipLastByte); static String encodeBase90Unsigned(long value); static String encodeBase90Signed(long value); static String encodeBytesBase90(byte[] bytes); static byte[] decodeBytesBase90(CharSequence charSequence); static long decodeBase90(CharSequence charSequence, boolean signed); static long decodeBase45(CharSequence charSequence); static final int MIDDLE_CHAR; }