Created
December 27, 2011 04:12
-
-
Save sunils34/1522686 to your computer and use it in GitHub Desktop.
base58_decode. - Decode Flickr shortened URLs
This file contains hidden or 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
//Given a base58 encoded string, obtain the base 10 number. | |
//This is useful for decoding shortened flickr urls. | |
function base58_decode( snipcode ) | |
{ | |
var alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' ; | |
var num = snipcode.length ; | |
var decoded = 0 ; | |
var multi = 1 ; | |
for ( var i = (num-1) ; i >= 0 ; i-- ) | |
{ | |
decoded = decoded + multi * alphabet.indexOf( snipcode[i] ) ; | |
multi = multi * alphabet.length ; | |
} | |
return decoded; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment