models.py 文件源码

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

项目:fomalhaut-panel 作者: restran 项目源码 文件源码
def get_hexdigest(algorithm, salt, raw_password):
    """
    Returns a string of the hexdigest of the given plaintext password and salt
    using the given algorithm ('md5', 'sha1' or 'crypt').
    """
    raw_password, salt = smart_str(raw_password), smart_str(salt)
    if algorithm == 'crypt':
        try:
            import crypt
        except ImportError:
            raise ValueError('"crypt" password algorithm not supported in this environment')
        return crypt.crypt(raw_password, salt)

    if algorithm == 'md5':
        return hashlib.md5(salt + raw_password).hexdigest()
    elif algorithm == 'sha1':
        return hashlib.sha1(salt + raw_password).hexdigest()
    elif algorithm == 'sha256':
        return hashlib.sha256(salt + raw_password).hexdigest()
    raise ValueError("Got unknown password algorithm type in password.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号