Ë
    àU.j±  ã                   óä   — 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mZ ddlmc mZ dgZ G d„ dej$                  ej&                  ej(                  ej*                  «      Zy)zÝpasslib.handlers.phpass - PHPass Portable Crypt

phppass located - http://www.openwall.com/phpass/
algorithm described - http://www.openwall.com/articles/PHP-Users-Passwords

phpass context - blowfish, bsdi_crypt, phpass
é    )Úmd5N)Úh64)ÚuÚuascii_to_strÚunicodeÚphpassc                   óè   — e Zd ZdZd ZdZej                  ZdxZ	Z
ej                  ZdZdZdZdZ ed«      Z ed«       ed	«      fZ ed
«       ed«       ed«       ed	«      iZed„ «       Zd„ Zd„ Zy)r   a€  This class implements the PHPass Portable Hash, and follows the :ref:`password-hash-api`.

    It supports a fixed-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, one will be autogenerated (this is recommended).
        If specified, it must be 8 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 19, must be between 7 and 30, inclusive.
        This value is logarithmic, the actual number of iterations used will be :samp:`2**{rounds}`.

    :type ident: str
    :param ident:
        phpBB3 uses ``H`` instead of ``P`` for its identifier,
        this may be set to ``H`` in order to generate phpBB3 compatible hashes.
        it defaults to ``P``.

    :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
    )ÚsaltÚroundsÚidenté   é   é   é   Úlog2z$P$z$H$ÚPÚHc                 ó¬   — | j                  |«      \  }}|d   |dd |dd  }}} | |t        j                  |j                  d«      «      ||xs d ¬«      S )Nr   é   é	   Úascii)r   r   r
   Úchecksum)Ú_parse_identr   Údecode_int6Úencode)ÚclsÚhashr   Údatar   r
   Úchks          úYC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/phpass.pyÚfrom_stringzphpass.from_string`   sb   € à×&Ñ& tÓ,‰ˆˆtØ  ™G T¨!¨A Y°°Q°R°�c�ˆÙØÜ—?‘? 6§=¡=°Ó#9Ó:ØØ’[˜Dô	
ð 	
ó    c                 óê   — t        d«      | j                  t        j                  | j                  «      j                  d«      | j                  | j                  xs t        d«      fz  }t        |«      S )Nz%s%s%s%sr   Ú )	r   r   r   Úencode_int6r   Údecoder
   r   r   )Úselfr   s     r    Ú	to_stringzphpass.to_stringk   sZ   € Ü�‹} §
¡
Ü!Ÿo™o¨d¯k©kÓ:×AÑAÀ'ÓJØ"Ÿi™iØ"Ÿm™mÒ4¬q°«uð 6ñ 6ˆô ˜TÓ"Ð"r"   c                 óp  — t        |t        «      r|j                  d«      }d| j                  z  }t	        | j
                  j                  d«      |z   «      j                  «       }d}||k  r't	        ||z   «      j                  «       }|dz  }||k  rŒ't        j                  |«      j                  d«      S )Nzutf-8r   r   r   )
Ú
isinstancer   r   r   r   r
   Údigestr   Úencode_bytesr&   )r'   ÚsecretÚreal_roundsÚresultÚrs        r    Ú_calc_checksumzphpass._calc_checksumu   s¡   € ä�fœgÔ&Ø—]‘] 7Ó+ˆFØ˜Ÿ™‘nˆÜ�T—Y‘Y×%Ñ% gÓ.°Ñ7Ó8×?Ñ?ÓAˆØˆØ�+ŠoÜ˜ &™Ó)×0Ñ0Ó2ˆFØ�‰FˆAð �+‹oô ×Ñ Ó'×.Ñ.¨wÓ7Ð7r"   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚsetting_kwdsÚuhÚHASH64_CHARSÚchecksum_charsÚmin_salt_sizeÚmax_salt_sizeÚ
salt_charsÚdefault_roundsÚ
min_roundsÚ
max_roundsÚrounds_costr   Údefault_identÚident_valuesÚident_aliasesÚclassmethodr!   r(   r1   © r"   r    r   r      s¡   „ ñ!ðN €DØ.€LØ—_‘_€Nð %&Ð%€M�MØ—‘€Jð €NØ€JØ€JØ€Kñ �e“H€MÙ�e“H™a ›hÐ'€LÙ�s“V™A˜e›H¡a¨£f©Q¨u«XÐ6€Mð ñ
ó ð
ò#ó
8r"   )r5   Úhashlibr   ÚloggingÚ	getLoggerr2   ÚlogÚpasslib.utils.binaryr   Úpasslib.utils.compatr   r   r   Úpasslib.utils.handlersÚutilsÚhandlersr8   Ú__all__ÚHasManyIdentsÚ	HasRoundsÚHasSaltÚGenericHandlerr   rF   r"   r    Ú<module>rU      si   ðñõ Û Ð'�g×'Ñ'¨Ó1�õ %ß :Ñ :ß #Ð #ð ð€ôd8ˆR×Ñ˜rŸ|™|¨R¯Z©Z¸×9JÑ9Jõ d8r"   