stuppid_bot

Untitled

May 7th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ( function() {
  2.     var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  3.    
  4.     base62 = {
  5.         encode: function(n) {
  6.             var s = '';
  7.            
  8.             do {
  9.                 s = chars[n % 62] + s;
  10.             }
  11.             while ( n = Math.floor(n / 62) );
  12.            
  13.             return s;
  14.         },
  15.        
  16.         decode: function(s) {
  17.             var q = s.length,
  18.                 w,
  19.                 e = 0,
  20.                 r = 0;
  21.                
  22.             while (q--) {
  23.                 if ( w = chars.indexOf(s[q]) ) {
  24.                     r += w * Math.pow(62, e);
  25.                 }
  26.                
  27.                 ++e;
  28.             }
  29.            
  30.             return r;
  31.         }
  32.     }
  33. } )();
Advertisement
Add Comment
Please, Sign In to add comment