%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__/windows.cpython-39.pyc

a

f�Wc`0�@s�dZddlmZddlZe�e�ZddlmZddl	m
Z
mZddlm
Z
ddlmZed�jZddlmmZgd	�ZGd
d�dejejej�ZGdd
�d
ej�Zejdedddd�ZGdd�dejej�ZGdd�dejej�Z dS)z;passlib.handlers.nthash - Microsoft Windows -related hashes�)�hexlifyN)�warn)�
to_unicode�right_pad_string)�unicode)�lookup_hash�md4)�lmhash�nthash�
bsd_nthash�msdcc�msdcc2c@sPeZdZdZdZdZejZdZ	dZ
dZedd��Z
dd	�Zd
Zeddd
��ZdS)r	a�This class implements the Lan Manager Password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts a single
    optional keyword:

    :param bool truncate_error:
        By default, this will silently truncate passwords larger than 14 bytes.
        Setting ``truncate_error=True`` will cause :meth:`~passlib.ifc.PasswordHash.hash`
        to raise a :exc:`~passlib.exc.PasswordTruncateError` instead.

        .. versionadded:: 1.7

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.verify` methods accept a single
    optional keyword:

    :type encoding: str
    :param encoding:

        This specifies what character encoding LMHASH should use when
        calculating digest. It defaults to ``cp437``, the most
        common encoding encountered.

    Note that while this class outputs digests in lower-case hexadecimal,
    it will accept upper-case as well.
    )Ztruncate_error� ��cp437cCs|��S�N��lower��cls�hash�r�</usr/lib/python3.9/site-packages/passlib/handlers/windows.py�
_norm_hashUszlmhash._norm_hashcCs(|jr|�|�t|�||j���d�S�N�ascii)Zuse_defaultsZ_check_truncate_policyr�raw�encoding�decode��self�secretrrr�_calc_checksumYs
zlmhash._calc_checksumsKGS!@#$%NcCs�|s
|j}ddlm}|j}t|t�r6|���|�}nt|t�rJ|��}nt	d��t
|d�}||dd�|�||dd�|�S)a�encode password using LANMAN hash algorithm.

        :type secret: unicode or utf-8 encoded bytes
        :arg secret: secret to hash
        :type encoding: str
        :arg encoding:
            optional encoding to use for unicode inputs.
            this defaults to ``cp437``, which is the
            common case for most situations.

        :returns: returns string of raw bytes
        r)�des_encrypt_blockzsecret must be unicode or bytesr�)�default_encodingZpasslib.crypto.desr#�_magic�
isinstancer�upper�encode�bytes�	TypeErrorr)rr!rr#�MAGICrrrrcs



�z
lmhash.raw)N)�__name__�
__module__�__qualname__�__doc__�nameZsetting_kwds�uh�	HEX_CHARS�checksum_chars�
checksum_sizeZ
truncate_sizer%�classmethodrr"r&rrrrrr	s"
r	c@sLeZdZdZdZejZdZe	dd��Z
dd�Ze	dd��Ze	d
d
d��Z
dS)r
a�This class implements the NT Password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.

    Note that while this class outputs lower-case hexadecimal digests,
    it will accept upper-case digests as well.
    rcCs|��Srrrrrrr�sznthash._norm_hashcCst|�|���d�Sr)rrrrrrrr"�sznthash._calc_checksumcCs t|ddd�}t|�d����S)z�encode password using MD4-based NTHASH algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes

        :returns: returns string of raw bytes
        �utf-8r!�Zparam�	utf-16-le)rrr)�digest)rr!rrrr�sz
nthash.rawFcCs*tdt�t�|�}|r&t|��d�S|S)Nzfnthash.raw_nthash() is deprecated, and will be removed in Passlib 1.8, please use nthash.raw() insteadr)r�DeprecationWarningr
rrr)rr!�hex�retrrr�
raw_nthash�s
�
znthash.raw_nthashN)F)r-r.r/r0r1r2r3r4r5r6rr"rr>rrrrr
�s

r
rz$3$$aZThe class support FreeBSD's representation of NTHASH
    (which is compatible with the :ref:`modular-crypt-format`),
    and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.
    )�prefix�ident�docc@s>eZdZdZdZejZdZe	dd��Z
dd�Ze	dd��Zd	S)
raKThis class implements Microsoft's Domain Cached Credentials password hash,
    and follows the :ref:`password-hash-api`.

    It has a fixed number of rounds, and uses the associated
    username as the salt.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods
    have the following optional keywords:

    :type user: str
    :param user:
        String containing name of user account this password is associated with.
        This is required to properly calculate the hash.

        This keyword is case-insensitive, and should contain just the username
        (e.g. ``Administrator``, not ``SOMEDOMAIN\Administrator``).

    Note that while this class outputs lower-case hexadecimal digests,
    it will accept upper-case digests as well.
    rcCs|��Srrrrrrrszmsdcc._norm_hashcCst|�||j���d�Sr�rr�userrrrrrr"
szmsdcc._calc_checksumcCsDt|ddd��d�}t|ddd����d�}tt|���|���S)z�encode password using mscash v1 algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        r7r!r8r9rC)rr)rrr:)rr!rCrrrr
s	z	msdcc.rawN�
r-r.r/r0r1r2r3r4r5r6rr"rrrrrr�s
rc@s>eZdZdZdZejZdZe	dd��Z
dd�Ze	dd��Zd	S)
r
a�This class implements version 2 of Microsoft's Domain Cached Credentials
    password hash, and follows the :ref:`password-hash-api`.

    It has a fixed number of rounds, and uses the associated
    username as the salt.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods
    have the following extra keyword:

    :type user: str
    :param user:
        String containing name of user account this password is associated with.
        This is required to properly calculate the hash.

        This keyword is case-insensitive, and should contain just the username
        (e.g. ``Administrator``, not ``SOMEDOMAIN\Administrator``).
    rcCs|��Srrrrrrr3szmsdcc2._norm_hashcCst|�||j���d�SrrBrrrrr"7szmsdcc2._calc_checksumcCs`ddlm}t|ddd��d�}t|ddd����d�}tt|���|���}|d||d	d
�S)z�encode password using msdcc v2 algorithm

        :type secret: unicode or utf-8 bytes
        :arg secret: secret

        :type user: str
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        r)�pbkdf2_hmacr7r!r8r9rCZsha1i(�)�passlib.crypto.digestrErr)rrr:)rr!rCrE�tmprrrr:s
z
msdcc2.rawNrDrrrrr
s
r
)!r0ZbinasciirZloggingZ	getLoggerr-�log�warningsrZ
passlib.utilsrrZpasslib.utils.compatrrGr�constrZpasslib.utils.handlersZutils�handlersr2�__all__Z
TruncateMixinZHasEncodingContextZ
StaticHandlerr	r
Z
PrefixWrapperrZHasUserContextrr
rrrr�<module>s 
t3�*0

Zerion Mini Shell 1.0