當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。