Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/Crypto/Random/__init__.py: 80%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:03 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:03 +0000
1# -*- coding: utf-8 -*-
2#
3# Random/__init__.py : PyCrypto random number generation
4#
5# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
6#
7# ===================================================================
8# The contents of this file are dedicated to the public domain. To
9# the extent that dedication to the public domain is not available,
10# everyone is granted a worldwide, perpetual, royalty-free,
11# non-exclusive license to exercise all rights associated with the
12# contents of this file for any purpose whatsoever.
13# No rights are reserved.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22# SOFTWARE.
23# ===================================================================
25__revision__ = "$Id$"
26__all__ = ['new']
28from Crypto.Random import OSRNG
29from Crypto.Random import _UserFriendlyRNG
31def new(*args, **kwargs):
32 """Return a file-like object that outputs cryptographically random bytes."""
33 return _UserFriendlyRNG.new(*args, **kwargs)
35def atfork():
36 """Call this whenever you call os.fork()"""
37 _UserFriendlyRNG.reinit()
39def get_random_bytes(n):
40 """Return the specified number of cryptographically-strong random bytes."""
41 return _UserFriendlyRNG.get_random_bytes(n)
43# vim:set ts=4 sw=4 sts=4 expandtab: