| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/twisted/python/__pycache__/ |
Upload File : |
U
W[w � @ s� d Z ddlmZmZ ddlZddlZddlZddlZddlm Z e
edd�Ze rXej
Zndd� ZG dd � d e�ZG d
d� de�ZG dd
� d
e�Ze� ZejZejZ[ddd gZdS )zQ
Cryptographically secure random implementation, with fallback on normal random.
� )�division�absolute_importN)�_PY3�getrandbitsc C s
| � d�S )N�hex)�decode)�hexBytes� r �:/usr/lib/python3/dist-packages/twisted/python/randbytes.py�_fromhex s r c @ s e Zd ZdZdS )�SecureRandomNotAvailablezD
Exception raised when no secure random algorithm is found.
N��__name__�
__module__�__qualname__�__doc__r r r r
r s r c @ s e Zd ZdZdS )�SourceNotAvailablezQ
Internal exception used when a specific random source is not available.
Nr
r r r r
r s r c @ sf e Zd ZdZdZeZdd� Zddd�Zdd � Ze rBe
jZd
d� Z
nejZdd� Z
ed
d
�Zdd� ZdS )�
RandomFactoryz�
Factory providing L{secureRandom} and L{insecureRandom} methods.
You shouldn't have to instantiate this class, use the module level
functions instead: it is an implementation detail and could be removed or
changed arbitrarily.
r c
C s@ zt �|�W S ttfk
r: } zt|��W 5 d}~X Y nX dS )zO
Wrapper around C{os.urandom} that cleanly manage its absence.
N)�os�urandom�AttributeError�NotImplementedErrorr )�self�nbytes�er r r
�
_osUrandom5 s zRandomFactory._osUrandomFc C sL z| � |�W S tk
r Y nX |r@tjdtdd� | �|�S td��dS )ak
Return a number of secure random bytes.
@param nbytes: number of bytes to generate.
@type nbytes: C{int}
@param fallback: Whether the function should fallback on non-secure
random or not. Default to C{False}.
@type fallback: C{bool}
@return: a string of random bytes.
@rtype: C{str}
zPurandom unavailable - proceeding with non-cryptographically secure random source� )�category�
stacklevelz!No secure random source availableN)r r �warnings�warn�RuntimeWarning�insecureRandomr )r r Zfallbackr r r
�secureRandom? s
�
zRandomFactory.secureRandomc C s<