mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
remove out of date details in random numbers docs (#8482)
This commit is contained in:
parent
31f0dcabda
commit
f84327556a
1 changed files with 2 additions and 5 deletions
|
|
@ -18,16 +18,13 @@ you can obtain them with:
|
|||
>>> import os
|
||||
>>> iv = os.urandom(16)
|
||||
|
||||
This will use ``/dev/urandom`` on UNIX platforms, and ``BCryptGenRandom()`` on
|
||||
Windows.
|
||||
|
||||
If you need your random number as an integer (for example, for
|
||||
:meth:`~cryptography.x509.CertificateBuilder.serial_number`), you can use
|
||||
If you need your random number as an big integer, you can use
|
||||
``int.from_bytes`` to convert the result of ``os.urandom``:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> serial = int.from_bytes(os.urandom(20), byteorder="big")
|
||||
>>> serial = int.from_bytes(os.urandom(16), byteorder="big")
|
||||
|
||||
In addition, the `Python standard library`_ includes the ``secrets`` module,
|
||||
which can be used for generating cryptographically secure random numbers, with
|
||||
|
|
|
|||
Loading…
Reference in a new issue