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


Python FortunaAccumulator.min_pool_size方法代碼示例

本文整理匯總了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) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:26,代碼來源:test_FortunaAccumulator.py


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