utils.py 文件源码

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

项目:PythonGuru 作者: aronekob34 项目源码 文件源码
def generate_sha1(string, salt=None):

    if not isinstance(string, (str, text_type)):
        string = str(string)

    if not salt:
        salt = sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]

    salted_bytes = (smart_bytes(salt) + smart_bytes(string))
    hash_ = sha1(salted_bytes).hexdigest()

    return salt, hash_
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号