Created
February 9, 2010 23:14
-
-
Save engleek/299808 to your computer and use it in GitHub Desktop.
Base 62 String Decode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] strValDecode(String s) | |
{ | |
final String alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
BigInteger b = BigInteger.ZERO; | |
BigInteger b62 = new BigInteger("62"); | |
for (int i=0; i<s.length(); i++) { | |
int idx = alphabet.indexOf(s.codePointAt(i)); | |
b = b.multiply(b62).add(new BigInteger(Integer.toString(idx))); | |
} | |
return b.toByteArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment