当前位置: 首页>>代码示例>>Python>>正文


Python randpool.RandomPool方法代码示例

本文整理汇总了Python中Crypto.Util.randpool.RandomPool方法的典型用法代码示例。如果您正苦于以下问题:Python randpool.RandomPool方法的具体用法?Python randpool.RandomPool怎么用?Python randpool.RandomPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypto.Util.randpool的用法示例。


在下文中一共展示了randpool.RandomPool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runTest

# 需要导入模块: from Crypto.Util import randpool [as 别名]
# 或者: from Crypto.Util.randpool import RandomPool [as 别名]
def runTest(self):
        """Crypto.Util.randpool.RandomPool"""
        # Import the winrandom module and try to use it
        from Crypto.Util.randpool import RandomPool
        sys.stderr.write("SelfTest: You can ignore the RandomPool_DeprecationWarning that follows.\n")
        rpool = RandomPool()
        x = rpool.get_bytes(16)
        y = rpool.get_bytes(16)
        self.assertNotEqual(x, y)
        self.assertNotEqual(rpool.entropy, 0)

        rpool.randomize()
        rpool.stir('foo')
        rpool.add_event('foo') 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:16,代码来源:test_rpoolcompat.py

示例2: randomSource

# 需要导入模块: from Crypto.Util import randpool [as 别名]
# 或者: from Crypto.Util.randpool import RandomPool [as 别名]
def randomSource(r = randpool.RandomPool().get_bytes):
        return struct.unpack('H', r(2))[0] 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:4,代码来源:dns.py

示例3: createKey

# 需要导入模块: from Crypto.Util import randpool [as 别名]
# 或者: from Crypto.Util.randpool import RandomPool [as 别名]
def createKey(keySize=32):
    """Create a random key.

    @param keySize: a positive C{int} key length.
    @return: a random string of length C{keySize}.
    """
    try:
        return randpool.RandomPool(512).get_bytes(keySize)
    except AssertionError:
        # An AssertionError can come from Crypto/Random/_UserFriendlyRNG.py,
        # which produces an error "PID check failed. RNG must be re-initialized
        # after fork(). Hint: Try Random.atfork()".  This seems to only happen
        # when running locally (in development mode).
        atfork()
        return randpool.RandomPool(512).get_bytes(keySize) 
开发者ID:fluidinfo,项目名称:fluiddb,代码行数:17,代码来源:minitoken.py

示例4: _createIV

# 需要导入模块: from Crypto.Util import randpool [as 别名]
# 或者: from Crypto.Util.randpool import RandomPool [as 别名]
def _createIV():
    """Create a 16-byte initialization vector.

    @return: a C{str} initialization vector.
    """
    try:
        return randpool.RandomPool(512).get_bytes(16)
    except AssertionError:
        # An AssertionError can come from Crypto/Random/_UserFriendlyRNG.py,
        # which produces an error "PID check failed. RNG must be re-initialized
        # after fork(). Hint: Try Random.atfork()".  This seems to only happen
        # when running locally (in development mode).
        atfork()
        return randpool.RandomPool(512).get_bytes(16) 
开发者ID:fluidinfo,项目名称:fluiddb,代码行数:16,代码来源:minitoken.py


注:本文中的Crypto.Util.randpool.RandomPool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。