Positional notation

I wanted to understand how base notation worked and if I could write my own using any character set.

var base36      = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var base16      = "0123456789ABCDEF";
var cust_base16 = "|~}[,<\;:'!@#$%^";

function baseEncode(int, base) {
    var currentint = int, encoded = new Array();
    while(currentint != 0) {
        encoded.push(base.substr(currentint%base.length,1));
        currentint = parseInt(currentint/base.length);
    }
    return encoded.reverse().join('');
}

function baseDecode(hex, base) {
    var storedVal = 0;
    for(var i = 0; i<hex.length; i++) {
        storedVal = storedVal + (base.indexOf(hex.toUpperCase().substr(i,1)) * Math.pow(base.length, (hex.length - 1) - i));
    }
    return storedVal;
}

var rando = parseInt(Math.random()*100000),
    encodeTest = baseEncode(rando, cust_base16),
    decodeTest = baseDecode(encodeTest, cust_base16);
    console.log('number: ' + rando);
    console.log('encoded value: ' + encodeTest);
    console.log('decoded value: ' + decodeTest);