Ë
    àU.jBJ  ã                   ó†  — d Z ddlmZmZ ddlmZ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mZmZmZ ddlmZ ddlmc mZ g d	¢Z G d
„ dej8                  ej:                  ej<                  ej>                  «      Z dde	fd„Z! e!ddd ed«      ¬«      Z" e!ddd«      Z# e!ddd«      Z$ ejJ                  de"ddd¬«      Z& ejJ                  de#ddd¬«      Z' ejJ                  de$d d!d¬«      Z(d"Z) G d#„ d$ej8                  ej:                  ej<                  ej>                  «      Z* G d%„ d&ej8                  ejV                  ej>                  «      Z, G d'„ d(ej:                  ej<                  ej>                  «      Z- G d)„ d*ej8                  ej:                  ej<                  ej>                  «      Z.y)+z,passlib.handlers.pbkdf - PBKDF2 based hashesé    )ÚhexlifyÚ	unhexlify)Ú	b64encodeÚ	b64decodeN)Ú
to_unicode)Úab64_decodeÚab64_encode)Ústr_to_basciiÚuÚuascii_to_strÚunicode)Úpbkdf2_hmac)Úpbkdf2_sha1Úpbkdf2_sha256Úpbkdf2_sha512Úcta_pbkdf2_sha1Údlitz_pbkdf2_sha1Úgrub_pbkdf2_sha512c                   ód   — e Zd ZdZdZej                  ZdZdZ	dZ
dZdZdZdZed	„ «       Zd
„ Zd„ Zy)ÚPbkdf2DigestHandlerz1base class for various pbkdf2_{digest} algorithms©ÚsaltÚ	salt_sizeÚroundsé   é   Né   ì   ÿÿ Úlinearc                 óÐ   — t        j                  || j                  | ¬«      \  }}}t        |j	                  d«      «      }|rt        |j	                  d«      «      } | |||¬«      S )N)ÚhandlerÚascii©r   r   Úchecksum)ÚuhÚ	parse_mc3Úidentr   Úencode©ÚclsÚhashr   r   Úchks        úYC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/pbkdf2.pyÚfrom_stringzPbkdf2DigestHandler.from_string?   sW   € äŸL™L¨¨s¯y©yÀ#ÔFÑˆ��cÜ˜4Ÿ;™; wÓ/Ó0ˆÙÜ˜cŸj™j¨Ó1Ó2ˆCÙ˜& t°cÔ:Ð:ó    c                 óê   — t        | j                  «      j                  d«      }t        | j                  «      j                  d«      }t	        j
                  | j                  | j                  ||«      S ©Nr"   )r	   r   Údecoder$   r%   Ú
render_mc3r'   r   ©Úselfr   r,   s      r-   Ú	to_stringzPbkdf2DigestHandler.to_stringG   sQ   € Ü˜4Ÿ9™9Ó%×,Ñ,¨WÓ5ˆÜ˜$Ÿ-™-Ó(×/Ñ/°Ó8ˆÜ�}‰}˜TŸZ™Z¨¯©°d¸CÓ@Ð@r/   c                 óp   — t        | j                  || j                  | j                  | j                  «      S )N)r   Ú_digestr   r   Úchecksum_size©r5   Úsecrets     r-   Ú_calc_checksumz"Pbkdf2DigestHandler._calc_checksumL   s'   € ä˜4Ÿ<™<¨°·±¸D¿K¹KÈ×I[ÑI[Ó\Ð\r/   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úsetting_kwdsr%   ÚHASH64_CHARSÚchecksum_charsÚdefault_salt_sizeÚmax_salt_sizeÚdefault_roundsÚ
min_roundsÚ
max_roundsÚrounds_costr8   Úclassmethodr.   r6   r<   © r/   r-   r   r      s_   „ Ù;ð 3€LØ—_‘_€Nð ÐØ€Mð €NØ€JØ€JØ€Kð €Gð ñ;ó ð;òAó
]r/   r   ià.  c                 óØ   — d| z   }|€t        d«      | fz  }t        }t        ||ft        |||| |||dz  dz   dz  dt        | j	                  «       |j
                  |¬«      z  ¬«      «      S )	z;create new Pbkdf2DigestHandler subclass for a specific hashÚpbkdf2_z$pbkdf2-%s$é   é   é   a$  This class implements a generic ``PBKDF2-HMAC-%(digest)s``-based 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: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be between 0-1024 bytes.
        If not specified, a %(dsc)d byte salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to %(dsc)d bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to %(dr)d, 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.

        .. versionadded:: 1.6
    )ÚdigestÚdscÚdr)r>   Únamer'   r8   rF   r9   Úencoded_checksum_sizer@   )r   r   ÚtypeÚdictÚupperrD   )Ú	hash_nameÚdigest_sizer   r'   ÚmodulerT   Úbases          r-   Úcreate_pbkdf2_hashr]   P   s‰   € à�yÑ €DØ€}Ü�-Ó  I <Ñ/ˆÜ€DÜ��t�gœtØØØØØØ!Ø*¨1™}¨Q™°Ñ2ðô> �i—o‘oÓ'¨T×-CÑ-CÈÔ
Oñ?Pô( ó (ð (r/   Úsha1é   i¸ÿ z$pbkdf2$)r'   Úsha256é    iHq  Úsha512é@   i¨a  Úldap_pbkdf2_sha1z{PBKDF2}TÚldap_pbkdf2_sha256z{PBKDF2-SHA256}z$pbkdf2-sha256$Úldap_pbkdf2_sha512z{PBKDF2-SHA512}z$pbkdf2-sha512$s   -_c                   ót   — e Zd ZdZd ZdZ ed«      ZdZdZ	dZ
ej                  ZdZdZd	Zed
„ «       Zd„ Zd„ Zy)r   aë  This class implements Cryptacular's PBKDF2-based crypt algorithm, 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: bytes
    :param salt:
        Optional salt bytes.
        If specified, it may be any length.
        If not specified, a one will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 16 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 60000, 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.

        .. versionadded:: 1.6
    r   ú$p5k2$r_   r   r   r   r   r   c                 óæ   — t        j                  || j                  d| ¬«      \  }}}t        |j	                  d«      t
        «      }|rt        |j	                  d«      t
        «      } | |||¬«      S )Nr   )Úrounds_baser!   r"   r#   )r%   r&   r'   r   r(   ÚCTA_ALTCHARSr)   s        r-   r.   zcta_pbkdf2_sha1.from_stringÖ   s`   € ô ŸL™L¨¨s¯y©yÀbÐRUÔVÑˆ��cÜ˜Ÿ™ WÓ-¬|Ó<ˆÙÜ˜CŸJ™J wÓ/´Ó>ˆCÙ˜& t°cÔ:Ð:r/   c                 ó  — t        | j                  t        «      j                  d«      }t        | j                  t        «      j                  d«      }t        j                  | j                  | j                  ||d¬«      S )Nr"   r   ©rj   )	r   r   rk   r2   r$   r%   r3   r'   r   r4   s      r-   r6   zcta_pbkdf2_sha1.to_stringß   sW   € Ü˜Ÿ™¤LÓ1×8Ñ8¸ÓAˆÜ˜Ÿ™¤|Ó4×;Ñ;¸GÓDˆÜ�}‰}˜TŸZ™Z¨¯©°d¸CÈRÔPÐPr/   c                 óH   — t        d|| j                  | j                  d«      S )Nr^   r_   ©r   r   r   r:   s     r-   r<   zcta_pbkdf2_sha1._calc_checksumç   s   € ä˜6 6¨4¯9©9°d·k±kÀ2ÓFÐFr/   N)r=   r>   r?   r@   rT   rA   r   r'   r9   rD   rE   r   rF   rG   rH   rI   rJ   r.   r6   r<   rK   r/   r-   r   r   ’   sk   „ ñðJ €DØ2€LÙˆh‹K€EØ€Mð ÐØ€Mð !×/Ñ/€NØ€JØ€JØ€Kð ñ;ó ð;òQóGr/   r   c                   óž   — e Zd ZdZd ZdZ ed«      Z ed«      ZdZ	dZ
ej                  Zej                  ZdZdZd	Zed
„ «       Zd„ Zd„ Zd„ Zy)r   aC  This class implements Dwayne Litzenberger's PBKDF2-based crypt algorithm, 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 specified, it may be any length, but must use the characters in the regexp range ``[./0-9A-Za-z]``.
        If not specified, a 16 character salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 16 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 60000, 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.

        .. versionadded:: 1.6
    r   rh   z1000000000000000000000000000000000000000000000000=r   r   r   r   r   c                 óh   — t        j                  || j                  dd| ¬«      \  }}} | |||¬«      S )Nr   é�  )rj   rF   r!   r#   )r%   r&   r'   r)   s        r-   r.   zdlitz_pbkdf2_sha1.from_string9  s6   € äŸL™L¨¨s¯y©yÀbØ8;ÀSôJÑˆ��cá˜& t°cÔ:Ð:r/   c                 ó˜   — | j                   }|dk(  rd }t        j                  | j                  || j                  | j
                  d¬«      S ©Nrr   r   rm   )r   r%   r3   r'   r   r$   ©r5   r   s     r-   r6   zdlitz_pbkdf2_sha1.to_string?  s;   € Ø—‘ˆØ�SŠ=ØˆFÜ�}‰}˜TŸZ™Z¨°·±¸D¿M¹MÐWYÔZÐZr/   c                 ó„   — | j                   }|dk(  rd }t        j                  | j                  || j                  d d¬«      S rt   )r   r%   r3   r'   r   ru   s     r-   Ú_get_configzdlitz_pbkdf2_sha1._get_configE  s6   € Ø—‘ˆØ�SŠ=ØˆFÜ�}‰}˜TŸZ™Z¨°·±¸DÈbÔQÐQr/   c                 óˆ   — | j                  «       }t        d||| j                  d«      }t        |«      j	                  d«      S )Nr^   é   r"   )rw   r   r   r	   r2   )r5   r;   r   Úresults       r-   r<   z dlitz_pbkdf2_sha1._calc_checksumN  s<   € à×ÑÓ!ˆÜ˜V V¨T°4·;±;ÀÓCˆÜ˜6Ó"×)Ñ)¨'Ó2Ð2r/   N)r=   r>   r?   r@   rT   rA   r   r'   Ú_stub_checksumrD   rE   r%   rB   Ú
salt_charsr   rF   rG   rH   rI   rJ   r.   r6   rw   r<   rK   r/   r-   r   r   ò   s~   „ ñðJ €DØ2€LÙˆh‹K€EÙ�~Ó&€Nð ÐØ€MØ—‘€Jð
 !×/Ñ/€NØ€JØ€JØ€Kð ñ;ó ð;ò
[òRó3r/   r   c                   óP   — e Zd ZdZd ZdZ ed«      ZdZdxZ	Z
ed„ «       Zd„ Zd„ Zy	)
Úatlassian_pbkdf2_sha1aB  This class implements the PBKDF2 hash used by Atlassian.

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

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

    :type salt: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be exactly 16 bytes.
        If not specified, a salt will be autogenerated (this is recommended).

    :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
    )r   z	{PKCS5S2}ra   r   c                 ó  — t        |dd«      }| j                  }|j                  |«      st        j                  j                  | «      ‚t        |t        |«      d  j                  d«      «      }|d d |dd  }} | ||¬«      S )Nr"   r+   r   )r   r$   )	r   r'   Ú
startswithr%   ÚexcÚInvalidHashErrorr   Úlenr(   )r*   r+   r'   Údatar   r,   s         r-   r.   z!atlassian_pbkdf2_sha1.from_string{  s|   € ä˜$ ¨Ó0ˆØ—	‘	ˆØ�‰˜uÔ%Ü—&‘&×)Ñ)¨#Ó.Ð.Ü˜œc %›j˜kÐ*×1Ñ1°'Ó:Ó;ˆØ˜˜"�I˜t B C˜yˆcˆÙ˜ sÔ+Ð+r/   c                 ó˜   — | j                   | j                  z   }| j                  t        |«      j	                  d«      z   }t        |«      S r1   )r   r$   r'   r   r2   r   )r5   r„   r+   s      r-   r6   zatlassian_pbkdf2_sha1.to_string…  s<   € Ø�y‰y˜4Ÿ=™=Ñ(ˆØ�z‰zœI d›O×2Ñ2°7Ó;Ñ;ˆÜ˜TÓ"Ð"r/   c                 ó4   — t        d|| j                  dd«      S )Nr^   i'  ra   )r   r   r:   s     r-   r<   z$atlassian_pbkdf2_sha1._calc_checksumŠ  s   € ô ˜6 6¨4¯9©9°e¸RÓ@Ð@r/   N)r=   r>   r?   r@   rT   rA   r   r'   r9   Úmin_salt_sizerE   rJ   r.   r6   r<   rK   r/   r-   r~   r~   [  sJ   „ ñð. #€DØ€LÙˆk‹N€EØ€Mð %'Ð&€M�Màñ,ó ð,ò#ó
Ar/   r~   c                   ót   — e Zd ZdZd ZdZ ed«      ZdZdZ	dZ
ej                  ZdZdZdZed	„ «       Zd
„ Zd„ Zy)r   aÿ  This class implements Grub's pbkdf2-hmac-sha512 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: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be between 0-1024 bytes.
        If not specified, a 64 byte salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 64 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 19000, 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.

        .. versionadded:: 1.6
    r   zgrub.pbkdf2.sha512.rc   r   r   r   r   c                 óä   — t        j                  || j                  t        d«      | ¬«      \  }}}t	        |j                  d«      «      }|rt	        |j                  d«      «      } | |||¬«      S )NÚ.)Úsepr!   r"   r#   )r%   r&   r'   r   r   r(   r)   s        r-   r.   zgrub_pbkdf2_sha512.from_stringÆ  s`   € äŸL™L¨¨s¯y©y¼aÀ»fØ14ô6Ñˆ��cä˜Ÿ™ WÓ-Ó.ˆÙÜ˜CŸJ™J wÓ/Ó0ˆCÙ˜& t°cÔ:Ð:r/   c           	      ó8  — t        | j                  «      j                  d«      j                  «       }t        | j                  «      j                  d«      j                  «       }t        j                  | j                  | j                  ||t        d«      ¬«      S )Nr"   rŠ   )r‹   )
r   r   r2   rX   r$   r%   r3   r'   r   r   r4   s      r-   r6   zgrub_pbkdf2_sha512.to_stringÏ  si   € Ü�t—y‘yÓ!×(Ñ(¨Ó1×7Ñ7Ó9ˆÜ�d—m‘mÓ$×+Ñ+¨GÓ4×:Ñ:Ó<ˆÜ�}‰}˜TŸZ™Z¨¯©°d¸CÄQÀsÃVÔLÐLr/   c                 óH   — t        d|| j                  | j                  d«      S )Nrb   rc   ro   r:   s     r-   r<   z!grub_pbkdf2_sha512._calc_checksumÔ  s   € ô ˜8 V¨T¯Y©Y¸¿¹ÀRÓHÐHr/   N)r=   r>   r?   r@   rT   rA   r   r'   r9   rD   rE   r   rF   rG   rH   rI   rJ   r.   r6   r<   rK   r/   r-   r   r   “  si   „ ñð@  €DØ2€LáÐ#Ó$€EØ€Mð ÐØ€Mà"×1Ñ1€NØ€JØ€JØ€Kàñ;ó ð;òMó
Ir/   r   )/r@   Úbinasciir   r   Úbase64r   r   ÚloggingÚ	getLoggerr=   ÚlogÚpasslib.utilsr   Úpasslib.utils.binaryr   r	   Úpasslib.utils.compatr
   r   r   r   Úpasslib.crypto.digestr   Úpasslib.utils.handlersÚutilsÚhandlersr%   Ú__all__Ú	HasRoundsÚ
HasRawSaltÚHasRawChecksumÚGenericHandlerr   r]   r   r   r   ÚPrefixWrapperrd   re   rf   rk   r   ÚHasSaltr   r~   r   rK   r/   r-   Ú<module>r¡      sª  ðÙ 2÷
 (ß 'Û Ð'�g×'Ñ'¨Ó1�õ %ß 9ß IÓ IÝ -ß #Ð #ò€ô1]˜"Ÿ,™,¨¯©°r×7HÑ7HÈ"×J[ÑJ[ô 1]ðf 7<À4ÐPXó .ñf ! ¨¨V¹1¸Z»=ÔI€Ù" 8¨R°Ó7€Ù" 8¨R°Ó7€à#�2×#Ñ#Ð$6¸ÀZÐQ[ÐcgÔhÐ Ø%�R×%Ñ%Ð&:¸MÐK\Ð^oÐw{Ô|Ð Ø%�R×%Ñ%Ð&:¸MÐK\Ð^oÐw{Ô|Ð ð €ôWG�b—l‘l B§M¡M°2×3DÑ3DÀb×FWÑFWô WGô@`3˜Ÿ™ b§j¡j°"×2CÑ2Cô `3ôR3A˜BŸM™M¨2×+<Ñ+<¸b×>OÑ>Oô 3AôpDI˜Ÿ™ r§}¡}°b×6GÑ6GÈ×IZÑIZõ DIr/   