customBase64 = function(num) {
const BASE_BITS = 6
const alphabet = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
let log = Math.log2(num)
if (Math.pow(2, Math.round(log)) === num) {
log++
}
let length = Math.max(1, Math.ceil(log / BASE_BITS))
let chars = new Array(length)
let x = chars.length - 1
while (num > 0) {
chars[x--] = alphabet[num % BASE]
num = Math.floor(num / BASE)
}
while (x >= 0) {
chars[x--] = alphabet[0]
}
return chars.join('')
}