HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/rsa/__pycache__/randnum.cpython-36.pyc
3

�Cb`�
�@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�\}}tj|�}|dkrJttjd��}|d|L}tjd|�|}|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�/usr/lib/python3.6/randnum.py�read_random_bitss
rcCs&t|�}tj|�}|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)�maxvaluercCsJtj|�}d}x6t|�}||kr"P|ddkr:|r:|d8}|d7}qW|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)rrZtriesrrrr�randintHs
r)�__doc__r
r
Zrsarr�int�bytesrrrrrrrr�<module>s