Convert the following key to an integer.

    @param key: a key.
    @param base: a sequence of characters that was used to encode the
           integer value.

    @return: the integer value corresponding to the given key.

    @raise ValueError: if one character of the specified key doesn't match
           any character of the specified base.

def key_to_int(key, base=BASE62):
    """
    Convert the following key to an integer.

    @param key: a key.
    @param base: a sequence of characters that was used to encode the
           integer value.

    @return: the integer value corresponding to the given key.

    @raise ValueError: if one character of the specified key doesn't match
           any character of the specified base.
    """
    base_length = len(base)

    value = 0
    for c in reversed(key):
        value = (value * base_length) + base.index(c)

    return value