本文整理匯總了Python中passlib.hash.bcrypt.encrypt方法的典型用法代碼示例。如果您正苦於以下問題:Python bcrypt.encrypt方法的具體用法?Python bcrypt.encrypt怎麽用?Python bcrypt.encrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類passlib.hash.bcrypt
的用法示例。
在下文中一共展示了bcrypt.encrypt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: hash_password
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def hash_password(password):
return bcrypt.encrypt(password, rounds=PASSWORD_HASH_ROUNDS)
示例2: get_password_hash_or_none
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def get_password_hash_or_none(password):
return bcrypt.encrypt(password) if password else None
# noinspection PyUnresolvedReferences
示例3: add
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def add(self, db, email, f_name, l_name, password, m_name=None):
password = bcrypt.encrypt(password)
insert_values = dict(f_name=f_name, m_name=m_name, l_name=l_name,
email=email, password=password)
if db.bind.name == 'mysql':
insert_values['created_at'] = datetime.datetime.utcnow()
insert_values['updated_at'] = datetime.datetime.utcnow()
self.user = User(**insert_values)
db.add(self.user)
db.commit()
return self.user
示例4: saveEditUser
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def saveEditUser(self, userId, name, username, password, type, iter,permission):
result = share.config.db.session.query(Users)
result = result.filter(Users.id == userId)
result[0].name = name
result[0].username = username
if password:
result[0].password = bcrypt.encrypt(password)
result[0].permission = self.groupId
share.config.db.session.commit()
示例5: __init__
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def __init__(self, name, username, password, permission, id=1):
self.name = name
self.username = username
self.password = bcrypt.encrypt(password)
self.permission = permission
示例6: read_passwords
# 需要導入模塊: from passlib.hash import bcrypt [as 別名]
# 或者: from passlib.hash.bcrypt import encrypt [as 別名]
def read_passwords():
""" Read passwords for all users from a password DB """
# Using an sqlite db for demo purpose
db = sqlite3.connect('passwd.db')
cursor = db.cursor()
hashes = {}
for user,passwd in cursor.execute("select user,password from passwds"):
hashes[user] = bcrypt.encrypt(passwd, rounds=8)
return hashes
開發者ID:PacktPublishing,項目名稱:Software-Architecture-with-Python,代碼行數:14,代碼來源:crytpo_password_compare.py