Ë
    àU.jñ  ã                   óö   — d Z ddlZ ej                  e«      ZddlmZmZ ddlm	Z	 ddl
mZmZmZ ddlmZ ddlmc mZ g ZdZ G d„ d	ej,                  ej.                  ej0                  ej2                  «      Zy)
zpasslib.handlers.sha1_crypt
é    N)Ú
safe_cryptÚ
test_crypt)Úh64)ÚuÚunicodeÚirange)Úcompile_hmacó    c                   óÄ   — e Zd ZdZd ZdZ ed«      ZdZe	j                  ZdZdZe	j                  ZdZdZd	Zd
Zed„ «       Zdd„ZdZed„ «       Zd„ Zed„ «       Zd„ Zg d¢Zy)Ú
sha1_crypta&  This class implements the SHA1-Crypt 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: str
    :param salt:
        Optional salt string.
        If not specified, an 8 character one will be autogenerated (this is recommended).
        If specified, it must be 0-64 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

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

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 480000, must be between 1 and 4294967295, inclusive.

    :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Ú	salt_sizeÚroundsz$sha1$é   é   é@   i S é   l   ÿÿ Úlinearc                 ód   — t        j                  || j                  | ¬«      \  }}} | |||¬«      S )N)Úhandler)r   r   Úchecksum)ÚuhÚ	parse_mc3Úident)ÚclsÚhashr   r   Úchks        ú]C:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/sha1_crypt.pyÚfrom_stringzsha1_crypt.from_stringS   s.   € äŸL™L¨¨s¯y©yÀ#ÔFÑˆ��cÙ˜& t°cÔ:Ð:ó    c                 óŽ   — |rd n| j                   }t        j                  | j                  | j                  | j
                  |«      S )N)r   r   Ú
render_mc3r   r   r   )ÚselfÚconfigr   s      r   Ú	to_stringzsha1_crypt.to_stringX   s0   € Ù‰d $§-¡-ˆÜ�}‰}˜TŸZ™Z¨¯©°d·i±iÀÓEÐEr    )Úos_cryptÚbuiltinc                 óT   — t        dd«      r| j                  | j                  «       yy)NÚtestz-$sha1$1$Wq3GL2Vp$C8U25GvfHS8qGHimExLaiSFlGkAeTF)r   Ú_set_calc_checksum_backendÚ_calc_checksum_os_crypt©r   s    r   Ú_load_backend_os_cryptz!sha1_crypt._load_backend_os_cryptd   s+   € ä�fð -ô .à×*Ñ*¨3×+FÑ+FÔGØàr    c                 ó  — | j                  d¬«      }t        ||«      }|€| j                  |«      S |j                  |«      rt	        |«      t	        |«      dz   k7  r!t
        j                  j                  | ||«      ‚|dd  S )NT)r$   é   iäÿÿÿ)r%   r   Ú_calc_checksum_builtinÚ
startswithÚlenr   ÚexcÚCryptBackendError)r#   Úsecretr$   r   s       r   r+   z"sha1_crypt._calc_checksum_os_cryptm   s{   € Ø—‘ t�Ó,ˆÜ˜& &Ó)ˆØˆ<ð ×.Ñ.¨vÓ6Ð6Ø�‰˜vÔ&¬#¨d«)´s¸6³{ÀRÑ7GÒ*GÜ—&‘&×*Ñ*¨4°¸Ó>Ð>Ø�C�DˆzÐr    c                 ó:   — | j                  | j                  «       y)NT)r*   r0   r,   s    r   Ú_load_backend_builtinz sha1_crypt._load_backend_builtin{   s   € à×&Ñ& s×'AÑ'AÔBØr    c                 ó¢  — t        |t        «      r|j                  d«      }t        |v rt        j
                  j                  | «      ‚| j                  }t        d«      | j                  |fz  j                  d«      }t        d|«      }t        |«      D ]
  } ||«      }Œ t        j                  || j                  «      j                  d«      S )Nzutf-8z
%s$sha1$%sÚasciiÚsha1)Ú
isinstancer   ÚencodeÚ_BNULLr   r3   ÚNullPasswordErrorr   r   r   r	   r   r   Úencode_transposed_bytesÚ_chk_offsetsÚdecode)r#   r5   r   ÚresultÚ
keyed_hmacÚ_s         r   r0   z!sha1_crypt._calc_checksum_builtin€   sª   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFÜ�VÑÜ—&‘&×*Ñ*¨4Ó0Ð0Ø—‘ˆä�L“/ T§Y¡Y°Ð$7Ñ7×?Ñ?ÀÓHˆä! &¨&Ó1ˆ
Ü˜–ˆAÙ Ó'‰Fð  ä×*Ñ*¨6°4×3DÑ3DÓE×LÑLÈWÓUÐUr    )é   r   r   é   é   é   r   é   é   é   é
   é	   é   é   é   é   é   é   r   é   é   N)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚsetting_kwdsr   r   Úchecksum_sizer   ÚHASH64_CHARSÚchecksum_charsÚdefault_salt_sizeÚmax_salt_sizeÚ
salt_charsÚdefault_roundsÚ
min_roundsÚ
max_roundsÚrounds_costÚclassmethodr   r%   Úbackendsr-   r+   r7   r0   r@   © r    r   r   r      s²   „ ñðJ €DØ2€LÙˆh‹K€EØ€MØ—_‘_€Nð ÐØ€MØ—‘€Jð €NØ€JØ€JØ€Kð
 ñ;ó ð;óFð '€Hð
 ñó ðò	ð ñó ðòVò�Lr    r   )rY   ÚloggingÚ	getLoggerrV   ÚlogÚpasslib.utilsr   r   Úpasslib.utils.binaryr   Úpasslib.utils.compatr   r   r   Úpasslib.crypto.digestr	   Úpasslib.utils.handlersÚutilsÚhandlersr   Ú__all__r=   ÚHasManyBackendsÚ	HasRoundsÚHasSaltÚGenericHandlerr   rh   r    r   Ú<module>rx      sn   ðñó Ð'�g×'Ñ'¨Ó1�÷ 1Ý $ß 3Ñ 3Ý .ß #Ð #ð€ð
 
€ô}�×#Ñ# R§\¡\°2·:±:¸r×?PÑ?Põ }r    