osa-filters.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:openstack-ansible-plugins 作者: openstack 项目源码 文件源码
def string_2_int(string):
    """Return the an integer from a string.

    The string is hashed, converted to a base36 int, and the modulo of 10240
    is returned.

    :param string: string to retrieve an int from
    :type string: ``str``
    :returns: ``int``
    """
    # Try to encode utf-8 else pass
    try:
        string = string.encode('utf-8')
    except AttributeError:
        pass
    hashed_name = hashlib.sha256(string).hexdigest()
    return int(hashed_name, 36) % 10240
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号