本文整理匯總了Python中Crypto.Random.Fortuna.FortunaAccumulator.min_pool_size方法的典型用法代碼示例。如果您正苦於以下問題:Python FortunaAccumulator.min_pool_size方法的具體用法?Python FortunaAccumulator.min_pool_size怎麽用?Python FortunaAccumulator.min_pool_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Crypto.Random.Fortuna.FortunaAccumulator
的用法示例。
在下文中一共展示了FortunaAccumulator.min_pool_size方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_accumulator_pool_length
# 需要導入模塊: from Crypto.Random.Fortuna import FortunaAccumulator [as 別名]
# 或者: from Crypto.Random.Fortuna.FortunaAccumulator import min_pool_size [as 別名]
def test_accumulator_pool_length(self):
"""FortunaAccumulator.FortunaAccumulator minimum pool length"""
fa = FortunaAccumulator.FortunaAccumulator()
# This test case is hard-coded to assume that FortunaAccumulator.min_pool_size is 64.
self.assertEqual(fa.min_pool_size, 64)
# The PRNG should not allow us to get random data from it yet
self.assertRaises(AssertionError, fa.random_data, 1)
# Add 60 bytes, 4 at a time (2 header + 2 payload) to each of the 32 pools
for i in range(15):
for p in range(32):
# Add the bytes to the pool
fa.add_random_event(2, p, b("XX"))
# The PRNG should not allow us to get random data from it yet
self.assertRaises(AssertionError, fa.random_data, 1)
# Add 4 more bytes to pool 0
fa.add_random_event(2, 0, b("XX"))
# We should now be able to get data from the accumulator
fa.random_data(1)