HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/rsa/__pycache__/randnum.cpython-310.pyc
o

j��`a
�@spdZddlZddlZddlmZmZdedefdd�Zdedefdd	�Z	dedefd
d�Z
dedefd
d�ZdS)z(Functions for generating random numbers.�N)�common�	transform�nbits�returncCsNt|d�\}}t�|�}|dkr%tt�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�nbytes�rbits�
randomdata�randomvalue�r�-/usr/lib/python3/dist-packages/rsa/randnum.py�read_random_bitss
rcCs&t|�}t�|�}|d|d>O}|S)z3Reads a random integer of approximately nbits bits.r)rr�	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�maxvaluecCsHt�|�}d}	t|�}||kr	|S|ddkr|r|d8}|d7}q)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.
    rT�
r)r�bit_sizer)rr�triesrrrr�randintHs
	��r)�__doc__r
r
�rsarr�int�bytesrrrrrrrr�<module>s