Generate fixed-length random string from your allowed character pool.

    :param length: total length of this string.
    :param allowed: allowed charset.

    Example::

        >>> import string
        >>> rand_str(32)
        H6ExQPNLzb4Vp3YZtfpyzLNPFwdfnwz6

def rand_str(length, allowed=CHARSET_ALPHA_DIGITS):
    """Generate fixed-length random string from your allowed character pool.

    :param length: total length of this string.
    :param allowed: allowed charset.

    Example::

        >>> import string
        >>> rand_str(32)
        H6ExQPNLzb4Vp3YZtfpyzLNPFwdfnwz6
    """
    res = list()
    for _ in range(length):
        res.append(random.choice(allowed))
    return "".join(res)