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


Python bcrypt.encrypt方法代码示例

本文整理汇总了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) 
开发者ID:rikonor,项目名称:vanguard-api,代码行数:4,代码来源:users.py

示例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 
开发者ID:CERT-Polska,项目名称:n6,代码行数:6,代码来源:models.py

示例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 
开发者ID:amitt001,项目名称:pygmy,代码行数:13,代码来源:user.py

示例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() 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:11,代码来源:user.py

示例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 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:7,代码来源:User.py

示例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


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