:py:mod:`pylibressl.rand` ========================= .. py:module:: pylibressl.rand .. autoapi-nested-parse:: Random number generation. When used with LibreSSL, it uses `arc4random` algorithm based on ChaCha. Usage example: >>> # We want to get 32 bytes from PRNG >>> from pylibressl.rand import get_random_bytes >>> random = get_random_bytes(32) Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 rand/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: pylibressl.rand.get_random_bytes pylibressl.rand.libressl_get_random_bytes pylibressl.rand.getrandbits .. py:function:: get_random_bytes(length) Get a string of random bytes with specified length. Uses system PRNG provided by Python. .. py:function:: libressl_get_random_bytes(length) Get a string of random bytes with specified length. Uses LibreSSL PRNG (system source + arc4random). .. py:function:: getrandbits(bit_number) Get an integer containing `bit_number` random bits. Analogous to `Crypto.Random.random.getrandbits` from pycrypto.