当前位置: 首页>>代码示例>>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;未经允许,请勿转载。