def hex2dec(hex, base=16):
    """ Like hex(), but to string """
    hex = hex.upper()
    retval = 0
    chars = '0123456789ABCDEF'
    for count in range(len(hex)):
        value = base ** count
        c = hex[-(count + 1)]
        if c in chars:
            retval += chars.index(c) * value
    return retval
