def itoa(value, alphabet, padding=None):
    """
    Converts an int value to a str, using the given alphabet.
    Padding can be computed as: ceil(log of max_val base alphabet_len)
    """
    if value < 0:
        raise ValueError("Only positive numbers are allowed")
    elif value == 0:
        return alphabet[0]

    result = ""
    base = len(alphabet)

    while value:
        value, rem = divmod(value, base)
        result = alphabet[rem] + result

    if padding:
        fill = max(padding - len(result), 0)
        result = (alphabet[0] * fill) + result

    return result