HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/rsa/__pycache__/randnum.cpython-37.pyc
B

��f�
�@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�</opt/alt/python37/lib/python3.7/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)�maxvaluercCsJt�|�}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)rr�triesrrrr�randintHs
r)�__doc__r
r
Zrsarr�int�bytesrrrrrrrr�<module>s