Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/rsa/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/rsa/__pycache__/randnum.cpython-38.pyc
U

O��g�
�@shdZddlZddlZddlmZmZeed�dd�Zeed�dd�Z	eed�d	d
�Z
eed�dd
�ZdS)z(Functions for generating random numbers.�N)�common�	transform)�nbits�returncCsNt|d�\}}t�|�}|dkrJtt�d��}|d|L}t�d|�|}|S)z�Reads 'nbits' random bits.

    If nbits isn't a whole number of bytes, an extra byte will be appended with
    only the lower bits set.
    �r��B)�divmod�os�urandom�ord�struct�pack)r�nbytesZrbits�
randomdataZrandomvalue�r�8/opt/cppython/lib/python3.8/site-packages/rsa/randnum.py�read_random_bitss
rcCs&t|�}t�|�}|d|d>O}|S)z3Reads a random integer of approximately nbits bits.r)rrZ	bytes2int)rr�valuerrr�read_random_int.s
rcCst|�}|dBS)zhReads a random odd integer of approximately nbits bits.

    >>> read_random_odd_int(512) & 1
    1
    r)r)rrrrr�read_random_odd_int;sr)�maxvaluercCsFt�|�}d}t|�}||kr qB|ddkr8|r8|d8}|d7}q|S)z�Returns a random integer x with 1 <= x <= maxvalue

    May take a very long time in specific situations. If maxvalue needs N bits
    to store, the closer maxvalue is to (2 ** N) - 1, the faster this function
    is.
    r�
r)r�bit_sizer)rr�triesrrrr�randintHs

r)�__doc__r
r
�rsarr�int�bytesrrrrrrrr�<module>s


F1le Man4ger