Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ( function() {
- var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
- base62 = {
- encode: function(n) {
- var s = '';
- do {
- s = chars[n % 62] + s;
- }
- while ( n = Math.floor(n / 62) );
- return s;
- },
- decode: function(s) {
- var q = s.length,
- w,
- e = 0,
- r = 0;
- while (q--) {
- if ( w = chars.indexOf(s[q]) ) {
- r += w * Math.pow(62, e);
- }
- ++e;
- }
- return r;
- }
- }
- } )();
Advertisement
Add Comment
Please, Sign In to add comment