def baseXencode(value, chars='0123456789abcdefghijklmnopqrstuvwxyz'):
    """
    Converts an integer to a base X string using charset. 
    Base is implied by charset = base36 by default 

    Based on: https://en.wikipedia.org/wiki/Base36

    raises ValueError if value cannot be converted to integer
    """
    base = len(chars)
    integer = int(value)
    sign = '-' if integer < 0 else ''
    integer = abs(integer)
    result = ''
    while integer > 0:
        integer, remainder = divmod(integer, base)
        result = chars[remainder] + result
    return sign + result
