utils/base64.js
function encode(number) {
        if (number === 0) {
            return '';
        }

        var quotient = Math.floor(number / 64);
        var remainder = number % 64;

        var digit;
        if (remainder < 10) {
            digit = '' + remainder;
        }
        else if (remainder < 36) {
            digit = String.fromCharCode(remainder + 55);
        }
        else if (remainder < 62) {
            digit = String.fromCharCode(remainder + 61);
        }
        else if (remainder === 62) {
            digit = '-';
        }
        else if (remainder === 63) {
            digit = '_';
        }

        return encode(quotient) + '' + digit;
    }
function encode(number) {
        if (number === 0) {
            return '';
        }

        var quotient = Math.floor(number / 64);
        var remainder = number % 64;

        var digit;
        if (remainder < 10) {
            digit = '' + remainder;
        }
        else if (remainder < 36) {
            digit = String.fromCharCode(remainder + 55);
        }
        else if (remainder < 62) {
            digit = String.fromCharCode(remainder + 61);
        }
        else if (remainder === 62) {
            digit = '-';
        }
        else if (remainder === 63) {
            digit = '_';
        }

        return encode(quotient) + '' + digit;
    }
function encode ( number ) { if ( number === 0 ) { return '' ; } var quotient = Math . floor ( number / 64 ) ; var remainder = number % 64 ; var digit ; if ( remainder < 10 ) { digit = '' + remainder ; } else if ( remainder < 36 ) { digit = String . fromCharCode ( remainder + 55 ) ; } else if ( remainder < 62 ) { digit = String . fromCharCode ( remainder + 61 ) ; } else if ( remainder === 62 ) { digit = '-' ; } else if ( remainder === 63 ) { digit = '_' ; } return encode ( quotient ) + '' + digit ; }
Take a number and translate it into our custom base64 encoded
string

@param number
@returns {string}
Take a number and translate it into our custom base64 encoded string