CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/randbytes.cpython-310.pyc

o

�b�
�@s|dZddlZddlZddlZeedd�ZejZGdd�de	�Z
Gdd�de	�ZGdd	�d	�Ze�Z
e
jZe
jZ[
gd
�ZdS)zQ
Cryptographically secure random implementation, with fallback on normal random.
�N�getrandbitsc@�eZdZdZdS)�SecureRandomNotAvailablezD
    Exception raised when no secure random algorithm is found.
    N��__name__�
__module__�__qualname__�__doc__�r
r
�:/usr/lib/python3/dist-packages/twisted/python/randbytes.pyr�rc@r)�SourceNotAvailablezQ
    Internal exception used when a specific random source is not available.
    Nrr
r
r
rr
rr
c@sReZdZdZdZeZdd�Zddd�Zdd	�Ze	j
Zed
d
�Zdd�Z
d
d�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
Cs2zt�|�WSttfy}zt|��d}~ww)zO
        Wrapper around C{os.urandom} that cleanly manage its absence.
        N)�os�urandom�AttributeError�NotImplementedErrorr
)�self�nbytes�er
r
r�
_osUrandom-s��zRandomFactory._osUrandomFcCsFz|�|�WStyYnw|rtjdtdd�|�|�Std��)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 available)rr
�warnings�warn�RuntimeWarning�insecureRandomr)rr�fallbackr
r
r�secureRandom6s
��
zRandomFactory.secureRandomcCs8|jdur|�|d�}d|d|}t|�Std��)z3
        Wrapper around C{os.getrandbits}.
        N�z%%0%dxrz#random.getrandbits is not available)r�_fromhexr
)rr�n�hexBytesr
r
r�	_randBitsSs

zRandomFactory._randBits�csd��fdd�t|�D��S)z6
        Wrapper around the C{random} module.
        r%csg|]}tt��j�g��qSr
)�bytes�random�choice�_BYTES)�.0�i�rr
r�
<listcomp>dsz-RandomFactory._randModule.<locals>.<listcomp>)�join�range)rrr
r,r�_randModule`szRandomFactory._randModulec	Cs4dD]}z
t||�|�WStyYqwdS)z�
        Return a number of non secure random bytes.

        @param nbytes: number of bytes to generate.
        @type nbytes: C{int}

        @return: a string of random bytes.
        @rtype: C{str}
        )r$r0N)�getattrr
)rr�srcr
r
rrfs
��zRandomFactory.insecureRandomN)F)rrrr	�
randomSourcesrrrr$r&�	maketrans�
_maketransr)r0rr
r
r
rrs	
	

r)rrr)r	rr'rr1rr&�fromhexr!�RuntimeErrorrr
r�factoryrr�__all__r
r
r
r�<module>sX
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY