%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/sun_md5_crypt.cpython-39.pyc

a

f�Wcm6�@sdZddlmZddlZddlZe�e�Zddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZmZddlmmZdgZd	aed
�Zedd�eD��ed
d�eD��edd�eD��edd�eD��gZ[dd�ZdZGdd�dej ej!ej"�Z#dS)z�passlib.handlers.sun_md5_crypt - Sun's Md5 Crypt, used on Solaris

.. warning::

    This implementation may not reproduce
    the original Solaris behavior in some border cases.
    See documentation for details.
�)�md5N)�warn)�
to_unicode)�h64)�byte_elem_value�irange�u�
uascii_to_str�unicode�
str_to_bascii�
sun_md5_crypts�To be, or not to be,--that is the question:--
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles,
And by opposing end them?--To die,--to sleep,--
No more; and by a sleep to say we end
The heartache, and the thousand natural shocks
That flesh is heir to,--'tis a consummation
Devoutly to be wish'd. To die,--to sleep;--
To sleep! perchance to dream:--ay, there's the rub;
For in that sleep of death what dreams may come,
When we have shuffled off this mortal coil,
Must give us pause: there's the respect
That makes calamity of so long life;
For who would bear the whips and scorns of time,
The oppressor's wrong, the proud man's contumely,
The pangs of despis'd love, the law's delay,
The insolence of office, and the spurns
That patient merit of the unworthy takes,
When he himself might his quietus make
With a bare bodkin? who would these fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death,--
The undiscover'd country, from whose bourn
No traveller returns,--puzzles the will,
And makes us rather bear those ills we have
Than fly to others that we know not of?
Thus conscience does make cowards of us all;
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought;
And enterprises of great pith and moment,
With this regard, their currents turn awry,
And lose the name of action.--Soft you now!
The fair Ophelia!--Nymph, in thy orisons
Be all my sins remember'd.
�ccs|]}|||dfVqdS)�N���.0�irr�B/usr/lib/python3.9/site-packages/passlib/handlers/sun_md5_crypt.py�	<genexpr>N�rccs |]}||d|dfVqdS)��NrrrrrrOrccs$|]}||d|dd@fVqdS)���NrrrrrrPrccs(|] }||dd@|dd@fVqdS)�	r�NrrrrrrQrcCst|t�sJ�t|t�sJ�|dkr(d}d|}t||���}t|�dksPJ�t\}}}}d}	|	|k�rdd�|D�j}
d}|
|	d?d@�|	d@?d	@r�|n|}|D]b\}
}}|
|�}|
|�}|
||d
?d@�||d@?d	@?}||
|d?d@�|d@?d	@|
>O}q�d}|
|	dd?d@�|	d@?d	@�r4|n|}|D]d\}
}}|
|�}|
|�}|
||d
?d@�||d@?d	@?}||
|d?d@�|d@?d	@|
>O}�q<|
|d?�|d@?|
|d?�|d@?Ad	@}t|�}|�r�|�t�|�t	|	��
d��|��}|	d	7}	q`t�|t
�S)
z:given secret & salt, return encoded sun-md5-crypt checksumri�cSsg|]}t|��qSr)r)r�crrr�
<listcomp>rz%raw_sun_md5_crypt.<locals>.<listcomp>rrr
r��@�ascii)�
isinstance�bytesr�digest�len�
_XY_ROUNDS�__getitem__�update�MAGIC_HAMLETr
�encoderZencode_transposed_bytes�_chk_offsets)�secret�rounds�saltZreal_rounds�resultZ
X_ROUNDS_0Z
X_ROUNDS_1Z
Y_ROUNDS_0Z
Y_ROUNDS_1�roundZrval�xZxroundsr�iaZib�a�b�v�yZyroundsZcoin�hrrr�raw_sun_md5_cryptUsB
$$&*$(,

r9)r�r�
r
r�r�rrrr �
rrcs�eZdZdZdZdZejZdZ	dZ
dZejZdZ
dZdZd	Zed
�ed�fZdZd�fd
d�	Zedd��Zedd��Zddd�Zdd�Z�ZS)raPThis class implements the Sun-MD5-Crypt password hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: str
    :param salt:
        Optional salt string.
        If not specified, a salt will be autogenerated (this is recommended).
        If specified, it must be drawn from the regexp range ``[./0-9A-Za-z]``.

    :type salt_size: int
    :param salt_size:
        If no salt is specified, this parameter can be used to specify
        the size (in characters) of the autogenerated salt.
        It currently defaults to 8.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 34000, must be between 0 and 4294963199, inclusive.

    :type bare_salt: bool
    :param bare_salt:
        Optional flag used to enable an alternate salt digest behavior
        used by some hash strings in this scheme.
        This flag can be ignored by most users.
        Defaults to ``False``.
        (see :ref:`smc-bare-salt` for details).

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    )r/r.�	bare_saltZ	salt_size�rNiЄrl�o�Zlinear�$md5$z$md5,Fcs ||_tt|�jfi|��dS�N)r?�superr�__init__)�selfr?�kwds��	__class__rrrD�szsun_md5_crypt.__init__cCst�|�}|�|j�SrB)�uhZto_unicode_for_identify�
startswith�ident_values)�cls�hashrrr�identifys
zsun_md5_crypt.identifyc
Cs�t|dd�}|�td��r$d}d}n�|�td��r�|�td�d�}|d	krXtj�|d
��|d|�}zt|�}Wn ty�tj�|d��Yn0|t	|�kr�tj�
|��|dkr�tj�|d��|d
}ntj�|��|�td�|�}|d	k�r||d�}d}d}	n�|t
|�d
k�rX||k�rB|dtd�k�rBtj�|d��||d	�}d}d}	nf|dk�r�||d
td�k�r�|||d
�}||d
d�}d}	n |||�}||d
d�}d}	|||||	d�S)Nr"rMrArr z$md5,rounds=�$r���zunexpected end of roundsz
bad roundszexplicit zero roundsrT���ztoo many '$' separatorsF)r.r/�checksumr?)rrJr�findrI�excZMalformedHashError�int�
ValueErrorr
ZZeroPaddedRoundsErrorZInvalidHashError�rfindr&)
rLrMr.Zsalt_idx�idxZrstrZchk_idxr/�chkr?rrr�from_stringsV

 �zsun_md5_crypt.from_stringTcCsn|jrtd�ntd�}|j}|dkr:td�||j|f}ntd�|j|f}|rf|j}td�||f}t|�S)N�rOrz$md5,rounds=%d$%s%sz	$md5$%s%sz%s$%s)r?rr.r/rRr	)rE�_withchk�ssr.rMrYrrr�	to_stringJszsun_md5_crypt.to_stringcCs8t|t�r|�d�}t|jdd��}t||j|��d�S)Nzutf-8F)r\r")r#r
r+rr^r9r.�decode)rEr-Zconfigrrr�_calc_checksum^s

zsun_md5_crypt._calc_checksum)F)T)�__name__�
__module__�__qualname__�__doc__�nameZsetting_kwdsrIZHASH64_CHARSZchecksum_charsZ
checksum_sizeZdefault_salt_sizeZ
max_salt_sizeZ
salt_charsZdefault_roundsZ
min_roundsZ
max_roundsZrounds_costrrKr?rD�classmethodrNrZr^r`�
__classcell__rrrGrr�s*,

C
)$rdZhashlibr�reZloggingZ	getLoggerra�log�warningsrZ
passlib.utilsrZpasslib.utils.binaryrZpasslib.utils.compatrrrr	r
rZpasslib.utils.handlersZutils�handlersrI�__all__r*Zxr�tupler'r9r,Z	HasRoundsZHasSaltZGenericHandlerrrrrr�<module>s,
 ��'�N

Zerion Mini Shell 1.0