本文整理汇总了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
示例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
)
示例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.')
示例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)
示例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?
示例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))
)
示例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)
示例8: __init__
# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def __init__(self):
self.hasher = argon2.PasswordHasher()
示例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
示例10: _store_password
# 需要导入模块: import argon2 [as 别名]
# 或者: from argon2 import PasswordHasher [as 别名]
def _store_password(self, password):
return PasswordHasher().hash(password)
示例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