Ë
    àU.jÙN  ã                   ó’  — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	Z	 e	j                  e«      ZddlmZ ddlmZmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZmZmZmZ ddlm Z  ddl!m"c m#Z$ g d¢Z%da&d„ Z'dZ( G d„ de$jR                  e$jT                  «      Z+ G d„ de$jX                  e+«      Z- G d„ de+«      Z. G d„ de+«      Z/ e$j`                  de ed«       ed«      d¬«      Z1de1_2        e1xjf                  dz  c_3         G d„ de«      Z4 G d„ d e-«      Z5 G d!„ d"e5«      Z6 e$j`                  d# ejn                  d$¬%«       ed&«       ed'«      d(¬)«      Z8d&e8_2        e8xjf                  dz  c_3         G d*„ d+e$jr                  e$jR                  e$jT                  «      Z: G d,„ d-e$jv                  jx                  e$jz                  «      Z>y).z5passlib.handlers.django- Django password hash supporté    )Ú	b64encode)Úhexlify)Úmd5Úsha1Úsha256N)Ú_wrapped_bcrypt)Úargon2ÚbcryptÚpbkdf2_sha1Úpbkdf2_sha256)Ú
to_unicodeÚrngÚ
getrandstr)ÚBASE64_CHARS)Ústr_to_uasciiÚuascii_to_strÚunicodeÚu)Úpbkdf2_hmac)Údjango_salted_sha1Údjango_salted_md5Údjango_bcryptÚdjango_pbkdf2_sha1Údjango_pbkdf2_sha256Údjango_argon2Údjango_des_cryptÚdjango_disabledc                  ó&   — t         €ddlm a  t         S )Nr   )Ú	des_crypt)r   Úpasslib.hash© ó    úYC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/django.pyÚ_import_des_cryptr$   &   s   € äÐÝ*ÜÐr"   Ú>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                   óN   — e Zd ZdZdZdZdZeZe	j                  Zed„ «       Zd„ Zy)ÚDjangoSaltedHashz2base class providing common code for django hashes)ÚsaltÚ	salt_sizeé   Nc                 ó`   — t        j                  || j                  | ¬«      \  }} | ||¬«      S )N©Úhandler©r(   Úchecksum)ÚuhÚ	parse_mc2Úident©ÚclsÚhashr(   Úchks       r#   Úfrom_stringzDjangoSaltedHash.from_stringB   s)   € ä—L‘L  s§y¡y¸#Ô>‰	ˆˆcÙ˜ sÔ+Ð+r"   c                 ól   — t        j                  | j                  | j                  | j                  «      S ©N)r0   Ú
render_mc2r2   r(   r/   ©Úselfs    r#   Ú	to_stringzDjangoSaltedHash.to_stringG   s!   € Ü�}‰}˜TŸZ™Z¨¯©°D·M±MÓBÐBr"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úsetting_kwdsÚdefault_salt_sizeÚmax_salt_sizeÚ
SALT_CHARSÚ
salt_charsr0   ÚLOWER_HEX_CHARSÚchecksum_charsÚclassmethodr7   r=   r!   r"   r#   r'   r'   2   sA   „ Ù<ð )€Lð ÐØ€MØ€Jà×'Ñ'€Nàñ,ó ð,óCr"   r'   c                   óH   — e Zd ZdZej
                  dz   ZdZed„ «       Zd„ Z	y)ÚDjangoVariableHashzEbase class providing common code for django hashes w/ variable rounds)Úroundsé   c                 ód   — t        j                  || j                  | ¬«      \  }}} | |||¬«      S )Nr,   )rL   r(   r/   )r0   Ú	parse_mc3r2   )r4   r5   rL   r(   r6   s        r#   r7   zDjangoVariableHash.from_stringQ   s.   € äŸL™L¨¨s¯y©yÀ#ÔFÑˆ��cÙ˜& t°cÔ:Ð:r"   c                 ó‚   — t        j                  | j                  | j                  | j                  | j
                  «      S r9   )r0   Ú
render_mc3r2   rL   r(   r/   r;   s    r#   r=   zDjangoVariableHash.to_stringV   s'   € Ü�}‰}˜TŸZ™Z¨¯©°d·i±iÀÇÁÓOÐOr"   N)
r>   r?   r@   rA   r'   rB   Ú
min_roundsrI   r7   r=   r!   r"   r#   rK   rK   K   s2   „ ÙOØ#×0Ñ0°;Ñ>€Là€Jàñ;ó ð;óPr"   rK   c                   ó2   — e Zd ZdZd ZdZ ed«      ZdZd„ Z	y)r   aÉ  This class implements Django's Salted SHA1 hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and uses a single round of SHA1.

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

    :type salt: str
    :param salt:
        Optional salt string.
        If not specified, a 12 character one will be autogenerated (this is recommended).
        If specified, may be any series of 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 12, but can be any positive value.

    This should be compatible with Django 1.4's :class:`!SHA1PasswordHasher` class.

    .. versionchanged: 1.6
        This class now generates 12-character salts instead of 5,
        and generated salts uses the character range ``[0-9a-zA-Z]`` instead of
        the ``[0-9a-f]``. This is to be compatible with how Django >= 1.4
        generates these hashes; but hashes generated in this manner will still be
        correctly interpreted by earlier versions of Django.
    r   zsha1$é(   c                 óÀ   — t        |t        «      r|j                  d«      }t        t	        | j
                  j                  d«      |z   «      j                  «       «      S ©Núutf-8Úascii)Ú
isinstancer   Úencoder   r   r(   Ú	hexdigest©r<   Úsecrets     r#   Ú_calc_checksumz!django_salted_sha1._calc_checksumy   sG   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFÜœT $§)¡)×"2Ñ"2°7Ó";¸fÑ"DÓE×OÑOÓQÓRÐRr"   N©
r>   r?   r@   rA   ÚnameÚdjango_namer   r2   Úchecksum_sizer^   r!   r"   r#   r   r   Y   s'   „ ñð4  €DØ€KÙˆg‹J€EØ€MóSr"   r   c                   ó2   — e Zd ZdZd ZdZ ed«      ZdZd„ Z	y)r   aâ  This class implements Django's Salted MD5 hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and uses a single round of MD5.

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

    :type salt: str
    :param salt:
        Optional salt string.
        If not specified, a 12 character one will be autogenerated (this is recommended).
        If specified, may be any series of 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 12, but can be any positive value.

    This should be compatible with the hashes generated by
    Django 1.4's :class:`!MD5PasswordHasher` class.

    .. versionchanged: 1.6
        This class now generates 12-character salts instead of 5,
        and generated salts uses the character range ``[0-9a-zA-Z]`` instead of
        the ``[0-9a-f]``. This is to be compatible with how Django >= 1.4
        generates these hashes; but hashes generated in this manner will still be
        correctly interpreted by earlier versions of Django.
    r   zmd5$é    c                 óÀ   — t        |t        «      r|j                  d«      }t        t	        | j
                  j                  d«      |z   «      j                  «       «      S rV   )rY   r   rZ   r   r   r(   r[   r\   s     r#   r^   z django_salted_md5._calc_checksumŸ   sG   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFÜœS §¡×!1Ñ!1°'Ó!:¸VÑ!CÓD×NÑNÓPÓQÐQr"   Nr_   r!   r"   r#   r   r   ~   s'   „ ñð6 €DØ€KÙˆf‹I€EØ€MóRr"   r   r   zbcrypt$aÇ  This class implements Django 1.4's BCrypt wrapper, and follows the :ref:`password-hash-api`.

    This is identical to :class:`!bcrypt` itself, but with
    the Django-specific prefix ``"bcrypt$"`` prepended.

    See :doc:`/lib/passlib.hash.bcrypt` for more details,
    the usage and behavior is identical.

    This should be compatible with the hashes generated by
    Django 1.4's :class:`!BCryptPasswordHasher` class.

    .. versionadded:: 1.6
    )Úprefixr2   Údocr
   )ra   c                   ól   ‡ — e Zd ZdZd ZdZeZ ed«      Z	e
d„ «       Ze
ˆ fd„«       Zˆ fd„Zˆ fd„Zˆ xZS )Údjango_bcrypt_sha256aš  This class implements Django 1.6's Bcrypt+SHA256 hash, and follows the :ref:`password-hash-api`.

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

    While the algorithm and format is somewhat different,
    the api and options for this hash are identical to :class:`!bcrypt` itself,
    see :doc:`bcrypt </lib/passlib.hash.bcrypt>` for more details.

    .. versionadded:: 1.6.2
    Úbcrypt_sha256zbcrypt_sha256$c                 óh   — t        j                  |«      }|sy|j                  | j                  «      S ©NF)r0   Úto_unicode_for_identifyÚ
startswithÚdjango_prefix©r4   r5   s     r#   Úidentifyzdjango_bcrypt_sha256.identifyÖ   s-   € ä×)Ñ)¨$Ó/ˆÙØØ�‰˜s×0Ñ0Ó1Ð1r"   c                 óH  •— t        |dd«      }|j                  | j                  «      st        j                  j                  | «      ‚|t        | j                  «      d  }|j                  d«      st        j                  j                  | «      ‚t        t        | �+  |«      S )NrX   r5   z$2)r   rn   ro   r0   ÚexcÚInvalidHashErrorÚlenÚMalformedHashErrorÚsuperri   r7   )r4   r5   ÚbhashÚ	__class__s      €r#   r7   z django_bcrypt_sha256.from_stringÝ   s†   ø€ ä˜$ ¨Ó0ˆØ�‰˜s×0Ñ0Ô1Ü—&‘&×)Ñ)¨#Ó.Ð.Ø”S˜×*Ñ*Ó+Ð,Ð-ˆØ×Ñ Ô%Ü—&‘&×+Ñ+¨CÓ0Ð0ÜÔ)¨3Ñ;¸EÓBÐBr"   c                 óX   •— t         t        | �  «       }t        | j                  «      |z   S r9   )rw   ri   r=   r   ro   )r<   rx   ry   s     €r#   r=   zdjango_bcrypt_sha256.to_stringç   s)   ø€ ÜÔ*¨DÑ;Ó=ˆÜ˜T×/Ñ/Ó0°5Ñ8Ð8r"   c                 ó¼   •— t        |t        «      r|j                  d«      }t        | j	                  |«      j                  «       «      }t        t        | �#  |«      S )NrW   )	rY   r   rZ   r   Ú_digestÚdigestrw   ri   r^   )r<   r]   ry   s     €r#   r^   z#django_bcrypt_sha256._calc_checksumë   sJ   ø€ Ü�fœgÔ&Ø—]‘] 7Ó+ˆFÜ˜Ÿ™ fÓ-×4Ñ4Ó6Ó7ˆÜÔ)¨4Ñ?ÀÓGÐGr"   )r>   r?   r@   rA   r`   ra   r   r|   r   ro   rI   rq   r7   r=   r^   Ú__classcell__)ry   s   @r#   ri   ri   À   s_   ø„ ñ	ð "€DØ!€KØ€Gñ Ð&Ó'€Màñ2ó ð2ð óCó ðCô9÷Hð Hr"   ri   c                   ón   — e Zd ZdZd ZdZ ed«      ZdZdZ	e
j                  ZdZej                  ZdZd„ Zy	)
r   aŒ  This class implements Django's PBKDF2-HMAC-SHA256 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 12 character one will be autogenerated (this is recommended).
        If specified, may be any series of 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 12, but can be any positive value.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 29000, but must be within ``range(1,1<<32)``.

    :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.

    This should be compatible with the hashes generated by
    Django 1.4's :class:`!PBKDF2PasswordHasher` class.

    .. versionadded:: 1.6
    r   zpbkdf2_sha256$rM   l   ÿÿ é,   r   c                 óª   — t        | j                  || j                  | j                  «      }t	        |«      j                  «       j                  d«      S )NrX   )r   r|   r(   rL   r   ÚrstripÚdecode)r<   r]   r5   s      r#   r^   z#django_pbkdf2_sha256._calc_checksum#  s<   € ä˜4Ÿ<™<¨°·±¸D¿K¹KÓHˆÜ˜‹×%Ñ%Ó'×.Ñ.¨wÓ7Ð7r"   N)r>   r?   r@   rA   r`   ra   r   r2   Úmin_salt_sizeÚ
max_roundsr0   ÚPADDED_BASE64_CHARSrH   rb   r   Údefault_roundsr|   r^   r!   r"   r#   r   r   õ   sN   „ ñ"ðF "€DØ!€KÙÐÓ€EØ€MØ€JØ×+Ñ+€NØ€MØ"×1Ñ1€NØ€Gó8r"   r   c                   óH   — e Zd ZdZd ZdZ ed«      ZdZe	j                  Z
dZy)r   a�  This class implements Django's PBKDF2-HMAC-SHA1 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 12 character one will be autogenerated (this is recommended).
        If specified, may be any series of 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 12, but can be any positive value.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 131000, but must be within ``range(1,1<<32)``.

    :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.

    This should be compatible with the hashes generated by
    Django 1.4's :class:`!PBKDF2SHA1PasswordHasher` class.

    .. versionadded:: 1.6
    r   zpbkdf2_sha1$é   r   N)r>   r?   r@   rA   r`   ra   r   r2   rb   r   r‡   r|   r!   r"   r#   r   r   (  s3   „ ñ"ðF  €DØ€KÙˆnÓ€EØ€MØ ×/Ñ/€NØ�Gr"   r   r   ÚI)Útyper	   zargon2$argon2i$aÒ  This class implements Django 1.10's Argon2 wrapper, and follows the :ref:`password-hash-api`.

    This is identical to :class:`!argon2` itself, but with
    the Django-specific prefix ``"argon2$"`` prepended.

    See :doc:`argon2 </lib/passlib.hash.argon2>` for more details,
    the usage and behavior is identical.

    This should be compatible with the hashes generated by
    Django 1.10's :class:`!Argon2PasswordHasher` class.

    .. versionadded:: 1.7
    )r`   Úwrappedrf   r2   rg   c                   óx   — e Zd ZdZd ZdZdZ ed«      Ze	j                  xZZdZdxZZdZdZed	„ «       Zd
„ Zd„ Zy)r   aß  This class implements Django's :class:`des_crypt` wrapper, and follows the :ref:`password-hash-api`.

    It supports a fixed-length salt.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept 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 2 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

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

        .. versionadded:: 1.7

    This should be compatible with the hashes generated by
    Django 1.4's :class:`!CryptPasswordHasher` class.
    Note that Django only supports this hash on Unix systems
    (though :class:`!django_des_crypt` is available cross-platform
    under Passlib).

    .. versionchanged:: 1.6
        This class will now accept hashes with empty salt strings,
        since Django 1.4 generates them this way.
    Úcrypt)r(   r)   Útruncate_errorzcrypt$é   é   é   Tc                 óÔ   — t        j                  || j                  | ¬«      \  }}|r8|s|d d }n+|d d |d d k7  r t         j                  j	                  | d«      ‚|dd  } | ||¬«      S )Nr,   r‘   z0first two digits of salt and checksum must matchr.   )r0   r1   r2   rs   rv   r3   s       r#   r7   zdjango_des_crypt.from_stringª  s}   € ä—L‘L  s§y¡y¸#Ô>‰	ˆˆcÙáð ˜2˜A�w‘Ø�b�q�˜S  !˜WÒ$ô —f‘f×/Ñ/°ØFóHð Hð �a�b�'ˆCÙ˜ sÔ+Ð+r"   c                 óÚ   — | j                   }|d d | j                  z   }| j                  r!t        j                  | j
                  ||«      S t        j                  | j
                  d|«      S )Nr‘   Ú )r(   r/   Úuse_duplicate_saltr0   r:   r2   )r<   r(   r6   s      r#   r=   zdjango_des_crypt.to_string½  sX   € Ø�y‰yˆØ�2�Aˆh˜Ÿ™Ñ&ˆØ×"Ò"ä—=‘= §¡¨T°3Ó7Ð7ô —=‘= §¡¨R°Ó5Ð5r"   c                 ó¬   — t         €
t        «        | j                  r| j                  |«       t        | j                  d d ¬«      j                  |«      S )Nr‘   )r(   )r   r$   Úuse_defaultsÚ_check_truncate_policyr(   r^   r\   s     r#   r^   zdjango_des_crypt._calc_checksumÇ  sG   € ô ÐÜÔà×ÒØ×'Ñ'¨Ô/Ü˜dŸi™i¨¨˜mÔ,×;Ñ;¸FÓCÐCr"   N)r>   r?   r@   rA   r`   ra   rB   r   r2   r0   ÚHASH64_CHARSrH   rF   rb   r„   rC   Útruncate_sizer–   rI   r7   r=   r^   r!   r"   r#   r   r   t  si   „ ñð: €DØ€KØ:€LÙˆh‹K€EØ"$§/¡/Ð1€N�ZØ€MØ()Ð)€MÐ%Ø€Mð Ðàñ,ó ð,ò$6ó	Dr"   r   c                   óN   — e Zd ZdZd Z ed«      ZdZed„ «       Z	d„ Z
ed„ «       Zy)r   aF  This class provides disabled password behavior for Django, and follows the :ref:`password-hash-api`.

    This class does not implement a hash, but instead
    claims the special hash string ``"!"`` which Django uses
    to indicate an account's password has been disabled.

    * newly encrypted passwords will hash to ``"!"``.
    * it rejects all passwords.

    .. note::

        Django 1.6 prepends a randomly generated 40-char alphanumeric string
        to each unusuable password. This class recognizes such strings,
        but for backwards compatibility, still returns ``"!"``.

        See `<https://code.djangoproject.com/ticket/20079>`_ for why
        Django appends an alphanumeric string.

    .. versionchanged:: 1.6.2 added Django 1.6 support

    .. versionchanged:: 1.7 started appending an alphanumeric string.
    Ú!rT   c                 ób   — t        j                  |«      }|j                  | j                  «      S r9   )r0   rm   rn   Ú_hash_prefixrp   s     r#   rq   zdjango_disabled.identifyî  s'   € ä×)Ñ)¨$Ó/ˆØ�‰˜s×/Ñ/Ó0Ð0r"   c                 óF   — t        t        t        d d | j                  «      S )Néþÿÿÿ)r   r   r   Úsuffix_lengthr\   s     r#   r^   zdjango_disabled._calc_checksumó  s   € äœ#œ|¨C¨RÐ0°$×2DÑ2DÓEÐEr"   c                 óŽ   — t        j                  |«       | j                  |«      st         j                  j	                  | «      ‚yrl   )r0   Úvalidate_secretrq   rs   rt   )r4   r]   r5   s      r#   Úverifyzdjango_disabled.verify÷  s4   € ä
×Ñ˜6Ô"Ø�|‰|˜DÔ!Ü—&‘&×)Ñ)¨#Ó.Ð.Ør"   N)r>   r?   r@   rA   r`   r   rŸ   r¢   rI   rq   r^   r¥   r!   r"   r#   r   r   Ò  sJ   „ ñð, €DÙ�S“6€LØ€Mð ñ1ó ð1òFð ñó ñr"   r   )?rA   Úbase64r   Úbinasciir   Úhashlibr   r   r   ÚloggingÚ	getLoggerr>   ÚlogÚpasslib.handlers.bcryptr   r    r	   r
   r   r   Úpasslib.utilsr   r   r   Úpasslib.utils.binaryr   Úpasslib.utils.compatr   r   r   r   Úpasslib.crypto.digestr   Úpasslib.utils.handlersÚutilsÚhandlersr0   Ú__all__r   r$   rE   ÚHasSaltÚGenericHandlerr'   Ú	HasRoundsrK   r   r   ÚPrefixWrapperr   ra   Ú_using_clone_attrsri   r   r   Úusingr   ÚTruncateMixinr   ÚifcÚDisabledHashÚStaticHandlerr   r!   r"   r#   Ú<module>r¿      sÂ  ðÙ ;õ
 Ý ß %Ñ %Û Ð'�g×'Ñ'¨Ó1�õ 4ß CÓ Cß 5Ñ 5Ý -ß IÓ IÝ -ß #Ð #ò	€ð  €	òð N€
ô
C�r—z‘z 2×#4Ñ#4ô Cô2P˜Ÿ™Ð'7ô Pô#SÐ)ô #SôJ$RÐ(ô $RðT !�× Ñ  °&ÙˆY‹<™q ›|ð	ô		€ð" %€Ô Ø ×  Ò  Ð$4Ñ 4Õ  ô/H˜?ô /Hôj18Ð-ô 18ôf)Ð-ô )ðd !�× Ñ Ø	ØˆF�L‰L˜cÔ"ÙˆX‹;Ù
ÐÓ
ð	ô	€ð( %€Ô Ø ×  Ò  Ð$4Ñ 4Õ  ô
\D�r×'Ñ'¨¯©°R×5FÑ5Fô \Dô|*�b—f‘f×)Ñ)¨2×+;Ñ+;õ *r"   