當前位置: 首頁>>代碼示例>>Python>>正文


Python pbkdf2_sha256.verify方法代碼示例

本文整理匯總了Python中passlib.hash.pbkdf2_sha256.verify方法的典型用法代碼示例。如果您正苦於以下問題:Python pbkdf2_sha256.verify方法的具體用法?Python pbkdf2_sha256.verify怎麽用?Python pbkdf2_sha256.verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在passlib.hash.pbkdf2_sha256的用法示例。


在下文中一共展示了pbkdf2_sha256.verify方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_verify_hash

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def test_verify_hash(self):
        """Test verify hash.

        Also needs app context to access config.
        """
        with self.app.app_context():
            hashed = self.app.config['PASSWORD_CONTEXT'].hash("some_pw")

            # Correct password
            self.assertTrue(
                verify_password({'password': hashed}, "some_pw")
            )

            # Wrong password
            self.assertFalse(
                verify_password({'password': hashed}, "NotThePassword")
            ) 
開發者ID:amiv-eth,項目名稱:amivapi,代碼行數:19,代碼來源:test_sessions.py

示例2: assertRehashed

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def assertRehashed(self, user_id, plaintext, old_hash):
        """Assert that the password was rehased.

        Check
        - that the password in the database is not the old hash
        - that the password in the datbase is a correct hash of the password

        Args:
            user_id (ObjectId): Id of user
            plaintext (str): Password of user as plaintext
            old_hash (str): Old hash of passwor
        """
        user = self.db['users'].find_one({'_id': user_id})

        self.assertNotEqual(user['password'], old_hash)

        self.assertTrue(pbkdf2_sha256.verify(plaintext, user['password'])) 
開發者ID:amiv-eth,項目名稱:amivapi,代碼行數:19,代碼來源:test_sessions.py

示例3: verifyUser

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def verifyUser(user, pwd):
  person = getUser(user)
  return (person and pbkdf2_sha256.verify(pwd, person['password'])) 
開發者ID:flipkart-incubator,項目名稱:watchdog,代碼行數:5,代碼來源:DatabaseLayer.py

示例4: checkpassword

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def checkpassword(self, pwd):
        return pbkdf2_sha256.verify(pwd, self.password) 
開發者ID:marcan,項目名稱:hackit,代碼行數:4,代碼來源:users.py

示例5: verify_password

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def verify_password(password, _hash):
        return pbkdf2_sha256.verify(password, _hash) 
開發者ID:afropolymath,項目名稱:papers,代碼行數:4,代碼來源:models.py

示例6: ValidateUser

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def ValidateUser(username, password):
    result = False
    try:
        user = GetUserInfo(username)
        if user is None:
            raise Exception("User not found")

        result = pbkdf2_sha256.verify(password, user.password)
    except:
        raise

    return result 
開發者ID:tech-quantum,項目名稱:sia-cog,代碼行數:14,代碼來源:projectmgr.py

示例7: check_password

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def check_password(self, password):
		return pbkdf2_sha256.verify(password, self.password) 
開發者ID:tspivey,項目名稱:yugioh-game,代碼行數:4,代碼來源:models.py

示例8: check_password

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def check_password(self, candidate_pw: str) -> bool:
        """Checks if the password is correct."""
        if self.auth_source != "internal" or self.password is None:
            return False
        return hash_algo.verify(candidate_pw, self.password) 
開發者ID:DistributedSystemsGroup,項目名稱:zoe,代碼行數:7,代碼來源:user.py

示例9: test_working_action

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def test_working_action(client):
    print('\n> links >{}'.format(User.actions))
    user = create_and_save_a_user('test user', 'test password', 'test description')
    rsp = client.get('/users/{}'.format(user.id))
    print('\nResponse: {} -> {}'.format(rsp.status, rsp.data))
    assert rsp.status_code == 200, 'the status code is expected to be 200'
    result = rsp.json
    assert result.get('_links') is not None
    assert 'change_password' in result.get('_links')
    assert 'get_description' in result.get('_links')
    assert 'self' in result.get('_links')
    assert 'collection' in result.get('_links')
    change_pass_included = False
    newpass = 'new pass'
    for link_name, link_value in result.get('_links').items():
        if link_name == 'change_password':
            change_pass_included = True
            post_data = json.dumps({'current_password': 'test password', 'new_password': newpass})
            assert link_value.get('href') is not None
            rsp = client.post(link_value.get('href'), data=post_data)
            print('\nResponse: {} -> {}'.format(rsp.status, rsp.data.decode))
            assert rsp.status_code == 200, 'the status code is expected to be 200'
            break
    assert change_pass_included, 'Should contain change_password link'
    rsp = client.get('/users/{}'.format(user.id))
    print('\nResponse: {} -> {}'.format(rsp.status, rsp.data.decode()))
    assert rsp.status_code == 200, 'the status code is expected to be 200'
    result = rsp.json
    assert 'password' not in result
    assert pbkdf2_sha256.verify(newpass, User.find_by_id(result.get('id')).password) 
開發者ID:accelero-cloud,項目名稱:appkernel,代碼行數:32,代碼來源:service_hateoas_test.py

示例10: change_p

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def change_p(self, current_password, new_password):
        if not pbkdf2_sha256.verify(current_password, self.password):
            raise ServiceException(403, _('Current password is not correct'))
        else:
            self.password = new_password
            self.save()
        return _('Password changed') 
開發者ID:accelero-cloud,項目名稱:appkernel,代碼行數:9,代碼來源:utils.py

示例11: validate

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def validate(username, password):
        user = User.query.filter(User._username == username).first()
        if user is not None and \
           pbkdf2_sha256.verify(password, user._password_hash):
            return user
        else:
            return None 
開發者ID:CryptoExperts,項目名稱:wb_contest_submission_server,代碼行數:9,代碼來源:user.py

示例12: verify

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def verify(self, password):
        return pbkdf2_sha256.verify(password, self._password_hash) 
開發者ID:CryptoExperts,項目名稱:wb_contest_submission_server,代碼行數:4,代碼來源:user.py

示例13: verify_hash

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def verify_hash(hash1, hash2):
    # https://passlib.readthedocs.io/en/stable/narr/hash-tutorial.html
    return pbkdf2_sha256.verify(hash1, hash2) 
開發者ID:geopython,項目名稱:GeoHealthCheck,代碼行數:5,代碼來源:util.py

示例14: validate_user

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def validate_user(username,password):
    try:
        results = db.query("SELECT * FROM users WHERE username=$username ORDER BY ROWID ASC LIMIT 1",
                           vars={'username': username})
        user = results[0]

        try:
            valid_hash = pbkdf2_sha256.verify(password, user.password)
        except ValueError as e:
            web.debug('%s user=%s' % (str(e), user.username))
            valid_hash = None
            pass
            
        date_now = datetime.datetime.now()
        date_expires = datetime.datetime.combine(user.expires, datetime.time.min)
        if date_now <= date_expires:
            if valid_hash:
                web.debug('login_success_hash: user=%s' % user.username)
                return user
            else:
                web.debug('login_failed_hash: incorrect password user=%s, fallback to plaintext' % user.username)
            
                if password == user.password:
                    web.debug('login_success_plaintext: user=%s' % user.username)
                    return user
                else:
                    web.debug('login_failed_plaintext: incorrect password user=%s' % user.username)
                    return None
        else:
            web.debug('login_failed: expired account user=%s' % user.username)
            return None
    
    except IndexError as e:
        web.debug('login_failed: not found user=%s' % username)
        return None 
開發者ID:ab77,項目名稱:netflix-proxy,代碼行數:37,代碼來源:auth.py

示例15: verify_hash

# 需要導入模塊: from passlib.hash import pbkdf2_sha256 [as 別名]
# 或者: from passlib.hash.pbkdf2_sha256 import verify [as 別名]
def verify_hash(password, hash):
        return sha256.verify(password, hash) 
開發者ID:roscisz,項目名稱:TensorHive,代碼行數:4,代碼來源:User.py


注:本文中的passlib.hash.pbkdf2_sha256.verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。