当前位置: 首页>>代码示例>>Python>>正文


Python argon2.PasswordHasher方法代码示例

本文整理汇总了Python中argon2.PasswordHasher方法的典型用法代码示例。如果您正苦于以下问题:Python argon2.PasswordHasher方法的具体用法?Python argon2.PasswordHasher怎么用?Python argon2.PasswordHasher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argon2的用法示例。


在下文中一共展示了argon2.PasswordHasher方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: passMatches

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def passMatches(accountPass, postPass):
    try:
        ph = PasswordHasher()
        ph.verify(accountPass, postPass)

        return True
    except:
        return False

# https://github.com/daviddrysdale/python-phonenumbers 
开发者ID:Gingernaut,项目名称:microAuth,代码行数:12,代码来源:utils.py

示例2: get_password_hasher

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def get_password_hasher(time_cost=None, memory_cost=None, parallelism=None,
                        hash_len=None, salt_len=None):
    """This function creates correct password hasher."""

    conf = CONF["common"]["password"]
    time_cost = time_cost or conf["time_cost"]
    memory_cost = memory_cost or conf["memory_cost"]
    parallelism = parallelism or conf["parallelism"]
    hash_len = hash_len or conf["hash_len"]
    salt_len = salt_len or conf["salt_len"]

    return argon2.PasswordHasher(
        time_cost=time_cost,
        memory_cost=memory_cost,
        parallelism=parallelism,
        hash_len=hash_len,
        salt_len=salt_len
    ) 
开发者ID:Mirantis,项目名称:ceph-lcm,代码行数:20,代码来源:passwords.py

示例3: login

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def login(username, password):
    ph = PasswordHasher()
    user = User.query.filter(db.func.lower(User.name) == username.lower()) \
        .first()
    try:
        if user:
            if ph.verify(user.password, want_bytes(password)):
                return user
            else:
                raise CtfException('Incorrect username or password.')
        else:
            # Defeat userame discovery
            ph.verify('', '')
    except VerificationError:
        raise CtfException('Incorrect username or password.')

    raise CtfException('Incorrect username or password.') 
开发者ID:WhiteHatCP,项目名称:wrath-ctf-framework,代码行数:19,代码来源:core.py

示例4: protege_senha_argon2

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def protege_senha_argon2(self, senha):
        """
        O Argon2 foi vencedor da edição 2015 da 'Password Hashing Competition'
        <https://password-hashing.net> e é indicado por muitos especialistas
        como a melhor solução para hash de senhas.

        ARGS:
        - senha (string): senha digitada pelo usuário.

        NOTAS
        1. O resultado de um hash Argon2 informa os parâmetros usados para
            obter aquele hash, além do próprio hash.
        2. Em ambientes de produção, esses parâmetros podem ser melhor
            configurados, como o tempo e a memória utilizados.

        """
        return PasswordHasher().hash(senha) 
开发者ID:forkd,项目名称:seguranca,代码行数:19,代码来源:seguranca.py

示例5: encryptPass

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def encryptPass(password):
    ph = PasswordHasher()
    return ph.hash(password)

# do this on the account class? 
开发者ID:Gingernaut,项目名称:microAuth,代码行数:7,代码来源:utils.py

示例6: make_passwd

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def make_passwd():
    username = raw_input('Username: ')
    password = getpass.getpass()
    password_verfiy = getpass.getpass('Verify Password:')
    if password != password_verfiy:
        print('Passwords differed, aborting')
    with open('passwd', 'w') as passwd_file:
        passwd_file.write(
            '{0}:{1}\n'.format(username, PasswordHasher().hash(password))
        ) 
开发者ID:grafoo,项目名称:webdmp,代码行数:12,代码来源:config.py

示例7: login

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def login():
    username = request.form['login_username']
    password = request.form['login_password']
    redirect_location = request.form['redirect_location']
    try:
        if PasswordHasher().verify(app.config['PASSWD'][username], password):
            session['authenticated'] = True
    except:
        print('login for {0} failed with wrong password'.format(username))
    return redirect(redirect_location) 
开发者ID:grafoo,项目名称:webdmp,代码行数:12,代码来源:webdmp.py

示例8: __init__

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def __init__(self):
        self.hasher = argon2.PasswordHasher() 
开发者ID:websauna,项目名称:websauna,代码行数:4,代码来源:password.py

示例9: create_user

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def create_user(username, password):
    if User.query.filter(db.func.lower(User.name) == username.lower()).count():
        raise CtfException('That username is taken.')
    pw_hash = PasswordHasher().hash(want_bytes(password))
    user = User(name=username, password=pw_hash)
    db.session.add(user)
    db.session.commit()
    return user 
开发者ID:WhiteHatCP,项目名称:wrath-ctf-framework,代码行数:10,代码来源:core.py

示例10: _store_password

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def _store_password(self, password):
        return PasswordHasher().hash(password) 
开发者ID:iffy,项目名称:humancrypto,代码行数:4,代码来源:y2016.py

示例11: _verify_password

# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def _verify_password(self, stored, password):
        ph = PasswordHasher()
        try:
            ph.verify(stored, password)
            return True
        except (exceptions.VerifyMismatchError, exceptions.VerificationError):
            return False 
开发者ID:iffy,项目名称:humancrypto,代码行数:9,代码来源:y2016.py


注:本文中的argon2.PasswordHasher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。