Ë
    àU.j`0  ã                   óà  — d Z ddlmZ ddlZ ej                  e«      ZddlmZ ddl	m
Z
mZ ddlmZ ddlmZ  ed«      j                   Zddlmc mZ g d	¢Z G d
„ dej.                  ej0                  ej2                  «      Z G d„ dej2                  «      Z ej8                  deddd¬«      Z G d„ dej<                  ej2                  «      Z G d„ dej<                  ej2                  «      Z y)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                   óh   — e Zd ZdZd ZdZej                  ZdZ	dZ
dZed„ «       Zd„ ZdZedd
„«       Zy	)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.
    )Útruncate_erroré    é   Úcp437c                 ó"   — |j                  «       S ©N©Úlower©ÚclsÚhashs     úZC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/windows.pyÚ
_norm_hashzlmhash._norm_hashU   ó   € à�z‰z‹|Ðó    c                 ó¤   — | j                   r| j                  |«       t        | j                  || j                  «      «      j                  d«      S ©NÚascii)Úuse_defaultsÚ_check_truncate_policyr   ÚrawÚencodingÚdecode©ÚselfÚsecrets     r   Ú_calc_checksumzlmhash._calc_checksumY   s>   € à×ÒØ×'Ñ'¨Ô/ä�t—x‘x ¨¯©Ó6Ó7×>Ñ>¸wÓGÐGr   s   KGS!@#$%Nc                 óD  — |s| j                   }ddlm} | j                  }t	        |t
        «      r |j                  «       j                  |«      }n,t	        |t        «      r|j                  «       }nt        d«      ‚t        |d«      } ||dd |«       ||dd |«      z   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_blockzsecret must be unicode or bytesr   é   )Údefault_encodingÚpasslib.crypto.desr,   Ú_magicÚ
isinstancer   ÚupperÚencodeÚbytesÚ	TypeErrorr   )r   r)   r%   r,   ÚMAGICs        r   r$   z
lmhash.rawc   s›   € ñ Ø×+Ñ+ˆHõ 	9Ø—
‘
ˆÜ�fœgÔ&ð —\‘\“^×*Ñ*¨8Ó4‰FÜ˜¤Ô&ð
 —\‘\“^‰FäÐ=Ó>Ð>Ü! &¨"Ó-ˆÙ  ¨¨! ¨eÓ4Ù  ¨¨" ¨uÓ5ñ6ð 	6r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚsetting_kwdsÚuhÚ	HEX_CHARSÚchecksum_charsÚchecksum_sizeÚtruncate_sizer.   Úclassmethodr   r*   r0   r$   © r   r   r
   r
      sf   „ ñðD €DØ&€Lð
 —\‘\€NØ€Mð
 €Mð
 Ðð
 ñó ðòHð €Fàò#6ó ñ#6r   r
   c                   óh   — e Zd ZdZd Zej                  ZdZe	d„ «       Z
d„ Ze	d„ «       Ze	dd„«       Zy)	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.
    r   c                 ó"   — |j                  «       S r   r   r   s     r   r   znthash._norm_hash¤   r   r   c                 óT   — t        | j                  |«      «      j                  d«      S r    )r   r$   r&   r'   s     r   r*   znthash._calc_checksum¨   s!   € Ü�t—x‘x Ó'Ó(×/Ñ/°Ó8Ð8r   c                 ón   — t        |dd¬«      }t        |j                  d«      «      j                  «       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)   ©Úparamú	utf-16-le)r   r	   r3   Údigest)r   r)   s     r   r$   z
nthash.raw«   s/   € ô ˜F G°8Ô<ˆä�6—=‘= Ó-Ó.×5Ñ5Ó7Ð7r   c                 óˆ   — t        dt        «       t        j                  |«      }|rt	        |«      j                  d«      S |S )Nzfnthash.raw_nthash() is deprecated, and will be removed in Passlib 1.8, please use nthash.raw() insteadr!   )r   ÚDeprecationWarningr   r$   r   r&   )r   r)   ÚhexÚrets       r   Ú
raw_nthashznthash.raw_nthash·   s>   € äð ?äô	!ô �j‰j˜Ó ˆÙ/2Œw�s‹|×"Ñ" 7Ó+Ð;¸Ð;r   N)F)r7   r8   r9   r:   r;   r=   r>   r?   r@   rB   r   r*   r$   rQ   rC   r   r   r   r   �   s]   „ ñð €DØ—\‘\€NØ€Mð
 ñó ðò9ð ñ	8ó ð	8ð ò<ó ñ<r   r   r   z$3$$aZ  The 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                   óV   — e Zd ZdZd Zej                  ZdZe	d„ «       Z
d„ Ze	d„ «       Zy)r   aK  This 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.
    r   c                 ó"   — |j                  «       S r   r   r   s     r   r   zmsdcc._norm_hash  r   r   c                 ój   — t        | j                  || j                  «      «      j                  d«      S r    ©r   r$   Úuserr&   r'   s     r   r*   zmsdcc._calc_checksum
  ó'   € Ü�t—x‘x ¨¯	©	Ó2Ó3×:Ñ:¸7ÓCÐCr   c                 óø   — t        |dd¬«      j                  d«      }t        |dd¬«      j                  «       j                  d«      }t        t        |«      j	                  «       |z   «      j	                  «       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
        rH   r)   rI   rK   rY   )r   r3   r   r	   rL   )r   r)   rY   s      r   r$   z	msdcc.raw  se   € ô ˜F G°8Ô<×CÑCÀKÓPˆÜ˜$ ¨vÔ6×<Ñ<Ó>×EÑEÀkÓRˆÜ”3�v“;×%Ñ%Ó'¨$Ñ.Ó/×6Ñ6Ó8Ð8r   N©r7   r8   r9   r:   r;   r=   r>   r?   r@   rB   r   r*   r$   rC   r   r   r   r   í   sH   „ ñð( €DØ—\‘\€NØ€Màñó ðòDð ñ
9ó ñ
9r   r   c                   óV   — e Zd ZdZd Zej                  ZdZe	d„ «       Z
d„ Ze	d„ «       Zy)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``).
    r   c                 ó"   — |j                  «       S r   r   r   s     r   r   zmsdcc2._norm_hash3  r   r   c                 ój   — t        | j                  || j                  «      «      j                  d«      S r    rX   r'   s     r   r*   zmsdcc2._calc_checksum7  rZ   r   c                 ó  — ddl m} t        |dd¬«      j                  d«      }t        |dd¬«      j	                  «       j                  d«      }t        t        |«      j                  «       |z   «      j                  «       } |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_hmacrH   r)   rI   rK   rY   Úsha1i (  é   )Úpasslib.crypto.digestra   r   r3   r   r	   rL   )r   r)   rY   ra   Útmps        r   r$   z
msdcc2.raw:  sz   € õ 	6Ü˜F G°8Ô<×CÑCÀKÓPˆÜ˜$ ¨vÔ6×<Ñ<Ó>×EÑEÀkÓRˆÜ”#�f“+×$Ñ$Ó&¨Ñ-Ó.×5Ñ5Ó7ˆÙ˜6 3¨¨e°RÓ8Ð8r   Nr\   rC   r   r   r   r     sH   „ ñð" €DØ—\‘\€NØ€Màñó ðòDð ñ9ó ñ9r   r   )!r:   Úbinasciir   ÚloggingÚ	getLoggerr7   ÚlogÚwarningsr   Úpasslib.utilsr   r   Úpasslib.utils.compatr   rd   r   Úconstr	   Úpasslib.utils.handlersÚutilsÚhandlersr=   Ú__all__ÚTruncateMixinÚHasEncodingContextÚStaticHandlerr
   r   ÚPrefixWrapperr   ÚHasUserContextr   r   rC   r   r   Ú<module>rw      sÜ   ðÙ Aõ
 Û Ð'�g×'Ñ'¨Ó1�Ý ÷ 7Ý (Ý -Ù�%Ó×Ñ€ß #Ð #ò€ôk6ˆR×Ñ˜r×4Ñ4°b×6FÑ6Fô k6ôh-<ˆR×Ñô -<ðf ˆR×Ñ˜l¨F¸6Èð	ô	€
ôT+9ˆB×Ñ˜r×/Ñ/ô +9ô`-9ˆR×Ñ × 0Ñ 0õ -9r   