本文整理汇总了Python中heartbeat.Heartbeat.random_challenge方法的典型用法代码示例。如果您正苦于以下问题:Python Heartbeat.random_challenge方法的具体用法?Python Heartbeat.random_challenge怎么用?Python Heartbeat.random_challenge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类heartbeat.Heartbeat
的用法示例。
在下文中一共展示了Heartbeat.random_challenge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Chunk
# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import random_challenge [as 别名]
class Chunk(object):
def __init__(self, file_path, num_challenges, root_seed):
self.secret = "mysecret"
self.target_file = Heartbeat(file_path, self.secret)
self.target_file.generate_challenges(num_challenges, root_seed)
def challenge(self):
return self.target_file.random_challenge()
def response(self, answer):
return self.target_file.check_answer(answer)
示例2: test_heartbeat_and_challenge
# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import random_challenge [as 别名]
def test_heartbeat_and_challenge(self):
file1 = Heartbeat(self.file_path, "mysecret")
file1.generate_challenges(10, self.root_seed)
challenge = file1.random_challenge()
# Create hash_response from seed and duplicate file
file2 = Heartbeat(self.file_path2)
answer = file2.meet_challenge(challenge)
self.assertTrue(file1.check_answer(answer))
# Create hash_answer from seed and edited file
file3 = Heartbeat(self.file_path3)
answer = file3.meet_challenge(challenge)
# This should not match
self.assertFalse(file1.check_answer(answer))