%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__/md5_crypt.cpython-39.opt-1.pyc

a

f�Wc�5�@s�dZddlmZddlZe�e�ZddlmZm	Z	m
Z
ddlmZddl
mZmZddlmmZddgZd	Zd
ZdZdZd
Zddd�ZGdd�dejej�ZGdd�deje�ZGdd�de�Z dS)z0passlib.handlers.md5_crypt - md5-crypt algorithm�)�md5N)�
safe_crypt�
test_crypt�
repeat_string)�h64)�unicode�u�	md5_crypt�
apr_md5_crypt�s$1$s$apr1$))r�����rr)r�r
r�rr)�rrr)rrrrr
)rrrr
)rrrr
r)��r�
�r��r��	rr�
r�Fcs�t|t�r|�d�}t|vr(tj�t��t|�}|�d�}|rDt	}nt
}t|||���}t|||�}|j
}|t||��|}|dd�}	|r�||d@r�tn|	�|dL}q�|��}
||}||}|||||||||g��fdd�tD�}
|
}d}|�r>|
D]&\}}t|t||������}�q
|d8}�q|
dd�D]&\}}t|t||������}�qJt�|t��d�S)	a�perform raw md5-crypt calculation

    this function provides a pure-python implementation of the internals
    for the MD5-Crypt algorithms; it doesn't handle any of the
    parsing/validation of the hash strings themselves.

    :arg pwd: password chars/bytes to hash
    :arg salt: salt chars to use
    :arg use_apr: use apache variant

    :returns:
        encoded checksum chars
    zutf-8�asciiNrcs g|]\}}�|�|f�qS�r)�.0�even�odd�Zpermsr�>/usr/lib/python3.9/site-packages/passlib/handlers/md5_crypt.py�
<listcomp>��z"_raw_md5_crypt.<locals>.<listcomp>��)�
isinstancer�encode�_BNULL�uh�excZNullPasswordErrorr	�len�
_APR_MAGIC�
_MD5_MAGICr�digest�updater�_c_digest_offsetsrZencode_transposed_bytes�_transpose_map�decode)�pwd�salt�use_aprZpwd_len�magicZdbZa_ctxZa_ctx_update�iZevenchar�daZpwd_pwdZpwd_salt�dataZdcZblocksr!r"rr#r$�_raw_md5_crypt,s@



.  r=c@s<eZdZdZdZdZejZdZ	ejZ
edd��Zdd�Z
d	S)
�_MD5_Commonz+common code for md5_crypt and apr_md5_crypt)r7Z	salt_size�rcCs"tj||j|d�\}}|||d�S)N)Zhandler)r7�checksum)r,Z	parse_mc2�ident)�cls�hashr7Zchkrrr$�from_string�sz_MD5_Common.from_stringcCst�|j|j|j�S�N)r,Z
render_mc2rAr7r@)�selfrrr$�	to_string�sz_MD5_Common.to_stringN)�__name__�
__module__�__qualname__�__doc__Zsetting_kwdsZ
checksum_sizer,ZHASH64_CHARSZchecksum_charsZ
max_salt_sizeZ
salt_chars�classmethodrDrGrrrr$r>�s
r>c@sHeZdZdZdZed�ZdZedd��Z	dd�Z
edd	��Zd
d�ZdS)
r	a�This class implements the MD5-Crypt password hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt.

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

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

    :type salt_size: int
    :param salt_size:
        Optional number of characters to use when autogenerating new salts.
        Defaults to 8, but can be any value between 0 and 8.
        (This is mainly needed when generating Cisco-compatible hashes,
        which require ``salt_size=4``).

    :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
        ``salt`` strings that are too long.

        .. versionadded:: 1.6
    z$1$)Zos_cryptZbuiltincCs"tdd�r|�|j�dSdSdS)N�testz$1$test$pi/xDtU5WFVRqYS6BMU8X/TF)r�_set_calc_checksum_backend�_calc_checksum_os_crypt�rBrrr$�_load_backend_os_crypts
z md5_crypt._load_backend_os_cryptcCsb|j|j}t||�}|dur(|�|�S|�|�rFt|�t|�dkrVtj�|||��|dd�S)Nr'i��)	rAr7r�_calc_checksum_builtin�
startswithr.r,r-ZCryptBackendError)rF�secretZconfigrCrrr$rOs

z!md5_crypt._calc_checksum_os_cryptcCs|�|j�dS)NT)rNrRrPrrr$�_load_backend_builtin%szmd5_crypt._load_backend_builtincCst||j�SrE�r=r7�rFrTrrr$rR*sz md5_crypt._calc_checksum_builtinN)
rHrIrJrK�namerrAZbackendsrLrQrOrUrRrrrr$r	�s 

c@s$eZdZdZdZed�Zdd�ZdS)r
apThis class implements the Apr-MD5-Crypt password hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt.

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

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

    :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
        ``salt`` strings that are too long.

        .. versionadded:: 1.6
    z$apr1$cCst||jdd�S)NT)r8rVrWrrr$�_calc_checksumQszapr_md5_crypt._calc_checksumN)rHrIrJrKrXrrArYrrrr$r
1s)F)!rKZhashlibrZloggingZ	getLoggerrH�logZ
passlib.utilsrrrZpasslib.utils.binaryrZpasslib.utils.compatrrZpasslib.utils.handlersZutils�handlersr,�__all__r+r0r/r3r4r=ZHasSaltZGenericHandlerr>ZHasManyBackendsr	r
rrrr$�<module>s&�

 Q

Zerion Mini Shell 1.0