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