+
    i_W                     :   R t ^ RIt^ RIt]P                  ! ]4      t^ RIHt ^ RIH	t	H
t
Ht ^ RIHtHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHu Ht . ROtRtR tR tR tR t  ! R R]PB                  ]PD                  ]PF                  ]PH                  4      t% ! R R]PD                  ]PL                  ]PF                  ]PH                  4      t' ! R R	]PF                  ]PH                  4      t( ! R R
]PB                  ]PF                  ]PH                  4      t)R# )zFpasslib.handlers.des_crypt - traditional unix (DES) crypt and variantsN)warn)
safe_crypt
test_crypt
to_unicode)h64h64big)byte_elem_valueuuascii_to_strunicodesuppress_cause)des_encrypt_int_block	des_crypt
bsdi_cryptbigcryptcrypt16    c                F    \        R \        V R,          4       4       4      # )zconvert secret to 64-bit DES key.

this only uses the first 8 bytes of the secret,
and discards the high 8th bit of each byte at that.
a null parity bit is inserted after every 7th bit of the output.
c              3   t   "   T F.  w  r\        V4      ^,          ^9V^,          ,
          ,          x  K0  	  R# 5i)   N)r   ).0ics   &  X/var/www/html/photoedit/myenv/lib/python3.14/site-packages/passlib/handlers/des_crypt.py	<genexpr>'_crypt_secret_to_key.<locals>.<genexpr>(   s3      2041  "T)r!A#v660s   68:N   N)sum	enumerate)secrets   &r   _crypt_secret_to_keyr       s'      2$VBZ02 2 2    c                   \        V4      ^8X  g   Q h\        P                  ! V4      p\        V \        4      '       d   V P                  R4      p \        V \        4      '       g   Q h\        V 9   d$   \        P                  P                  \        4      h\        V 4      p\        V^ V^4      p\        P                  ! V4      # )z pure-python backed for des_cryptutf-8)lenr   decode_int12
isinstancer   encodebytes_BNULLuhexcNullPasswordErrorr   r    r   r   encode_int64)r   salt
salt_value	key_valueresults   &&   r   _raw_des_cryptr2   +   s    t9>> !!$'J &'""w'fe$$$$ ff&&y11 %V,I #9aR@F v&&r!   c                    \        V 4      p^p\        V 4      pW#8  d-   V^,           p\        WV 4      p\        W4      V,          pTpK2  V# )z,convert secret to DES key used by bsdi_crypt)r    r$   r   )r   r0   idxendnext	tmp_values   &     r   _bsdi_secret_to_keyr8   I   sQ    $V,I
C
f+C
)Qw(D)9:	))?)K	r!   c                d   \         P                  ! V4      p\        V \        4      '       d   V P	                  R4      p \        V \
        4      '       g   Q h\        V 9   d$   \        P                  P                  \        4      h\        V 4      p\        V^ W14      p\        P                  ! V4      # )z"pure-python backend for bsdi_cryptr#   )r   decode_int24r&   r   r'   r(   r)   r*   r+   r,   r   r8   r   r   r-   )r   roundsr.   r/   r0   r1   s   &&&   r   _raw_bsdi_cryptr<   U   s     !!$'J &'""w'fe$$$$ ff&&z22 $F+I #9aDF v&&r!   c                      a  ] tR t^pt o RtR tRt]P                  t	^t
^;tt]P                  t^t]P                   ! ]! R4      ]P$                  ]P&                  ,          4      t]R 4       tR tR tRt]R 4       tR t]R 4       tR	 tR
tV tR# )r   aG  This class implements the des-crypt password hash, and follows the :ref:`password-hash-api`.

It supports a fixed-length salt.

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 2 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:param bool truncate_error:
    By default, 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

: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
zU
        ^
        (?P<salt>[./a-z0-9]{2})
        (?P<chk>[./a-z0-9]{11})?
        $c                d    \        VR R4      pVR,          VR,          r2T ! Y#;'       g    RR7      # )asciihash:N   NrA   NNNr.   checksum)r   )clsr@   r.   chks   &&  r   from_stringdes_crypt.from_string   s0    $0Hd2hc{{d33r!   c                h    \        R 4      V P                  V P                  3,          p\        V4      # z%s%sr	   r.   rD   r
   selfr@   s   & r   	to_stringdes_crypt.to_string   (    yDIIt}}55T""r!   c                j    V P                   '       d   V P                  V4       V P                  V4      # )N)use_defaults_check_truncate_policy_calc_checksum_backendrM   r   s   &&r   _calc_checksumdes_crypt._calc_checksum   s-    ''/**622r!   c                d    \        R R4      '       d   V P                  V P                  4       R# R# )testabgOeLfPimXQoTFr   _set_calc_checksum_backend_calc_checksum_os_cryptrE   s   &r   _load_backend_os_crypt des_crypt._load_backend_os_crypt   s)    fo..**3+F+FGr!   c                   \        WP                  4      pVf   V P                  V4      # VP                  V P                  4      '       d   \	        V4      ^8w  d+   \
        P                  P                  W P                  V4      hVR,          # )NrB   )r   r.   _calc_checksum_builtin
startswithr$   r*   r+   CryptBackendError)rM   r   r@   s   && r   r]   !des_crypt._calc_checksum_os_crypt   sk     &)),< ..v66tyy))SY"_&&**4DAABxr!   c                <    V P                  V P                  4       R # Tr\   rb   r^   s   &r   _load_backend_builtindes_crypt._load_backend_builtin       &&s'A'ABr!   c                h    \        WP                  P                  R 4      4      P                  R 4      # r?   )r2   r.   r'   decoderU   s   &&r   rb    des_crypt._calc_checksum_builtin   s'    fii&6&6w&?@GGPPr!    Nr.   truncate_erroros_cryptbuiltin) __name__
__module____qualname____firstlineno____doc__namesetting_kwdsr*   HASH64_CHARSchecksum_charschecksum_sizemin_salt_sizemax_salt_size
salt_charstruncate_sizerecompiler	   XI_hash_regexclassmethodrG   rN   rV   backendsr_   r]   ri   rb   __static_attributes____classdictcell____classdict__s   @r   r   r   p   s     H D-L
 __NM
 %&%MMJ
 M **Q    ttBDDy	K 4 4
#3 'H
  
  Q Qr!   c                   h  a a ] tR t^t oRtR tRt^t]P                  t
^;tt]P                  tRt^tRtRt]P&                  ! ]! R4      ]P*                  ]P,                  ,          4      t]R 4       tR tRt]V 3R	 l4       t]V 3R
 l4       tV 3R ltRt]R 4       t R t!]R 4       t"R t#Rt$Vt%V ;t&# )r   a  This class implements the BSDi-Crypt password 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 4 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 5001, must be between 1 and 16777215, 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

.. versionchanged:: 1.6
    :meth:`hash` will now issue a warning if an even number of rounds is used
    (see :ref:`bsdi-crypt-security-issues` regarding weak DES keys).
i  i linearz
        ^
        _
        (?P<rounds>[./a-z0-9]{4})
        (?P<salt>[./a-z0-9]{4})
        (?P<chk>[./a-z0-9]{11})?
        $c                (   \        VR R4      pV P                  P                  V4      pV'       g    \        P                  P                  V 4      hVP                  RRR4      w  r4pV ! \        P                  ! VP                  R 4      4      VVR7      # )r?   r@   r;   r.   rF   )r;   r.   rD   )
r   r   matchr*   r+   InvalidHashErrorgroupr   r:   r'   )rE   r@   mr;   r.   rF   s   &&    r   rG   bsdi_crypt.from_string4  s}    $0OO!!$'&&))#..GGHfe<c##FMM'$:;
 	
r!   c                    \        R 4      \        P                  ! V P                  4      P	                  R4      V P
                  V P                  3,          p\        V4      # )z_%s%s%sr?   )r	   r   encode_int24r;   rn   r.   rD   r
   rL   s   & r   rN   bsdi_crypt.to_stringA  sI    |s//<CCGL#yy$--9 9T""r!   Tc                   < \         \        V `
  ! R/ VB pVP                  ^,          '       g%   \	        R\
        P                  P                  4       V# )   zHbsdi_crypt rounds should be odd, as even rounds may reveal weak DES keysrp   )superr   usingdefault_roundsr   r*   r+   PasslibSecurityWarning)rE   kwdssubcls	__class__s   &, r   r   bsdi_crypt.usingN  sE    z3-55$$q(([..0r!   c                :   < \         \        V `  4       pV^,          # )r   )r   r   _generate_rounds)rE   r;   r   s   & r   r   bsdi_crypt._generate_roundsW  s    z38: axr!   c                b   < V P                   ^,          '       g   R# \        \        V `  ! R/ VB # )r   Trp   )r;   r   r   _calc_needs_update)rM   r   r   s   &,r   r   bsdi_crypt._calc_needs_updatee  s(    {{QZ9ADAAr!   c                d    \        R R4      '       d   V P                  V P                  4       R# R# )rY   z_/...lLDAxARksGCHin.TFr[   r^   s   &r   r_   !bsdi_crypt._load_backend_os_cryptt  s*    f455**3+F+FGr!   c                   V P                  4       p\        W4      pVf   V P                  V4      # VP                  VR,          4      '       d   \	        V4      ^8w  d!   \
        P                  P                  WV4      hVRR  # )N:N	   N)rN   r   rb   rc   r$   r*   r+   rd   )rM   r   configr@   s   &&  r   r]   "bsdi_crypt._calc_checksum_os_crypt|  sp    !&)< ..v66vbz**c$i2o&&**4>>CDzr!   c                <    V P                  V P                  4       R # rg   rh   r^   s   &r   ri    bsdi_crypt._load_backend_builtin  rk   r!   c                ~    \        WP                  V P                  P                  R 4      4      P	                  R 4      # rm   )r<   r;   r.   r'   rn   rU   s   &&r   rb   !bsdi_crypt._calc_checksum_builtin  s.    v{{DII4D4DW4MNUUV]^^r!   rp   )r.   r;   rs   )'rv   rw   rx   ry   rz   r{   r|   r   r*   r}   r~   r   r   r   r   
min_rounds
max_roundsrounds_costr   r   r	   r   r   r   r   rG   rN   _avoid_even_roundsr   r   r   r   r_   r]   ri   rb   r   r   __classcell__r   r   s   @@r   r   r      s
    F D%LM__N %&%MMJ NJJK **Q    ttBDDyK 

 

#    B 'H
  	  _ _r!   c                      a a ] tR tRt oRtR tR	t]P                  t	^;t
t]P                  t]P                  ! ]! R4      ]P                   ]P"                  ,          4      t]R 4       tR tR
V 3R lltR tRtVtV ;t# )r   i  a'  This class implements the BigCrypt password hash, and follows the :ref:`password-hash-api`.

It supports a fixed-length salt.

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 22 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

: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
zX
        ^
        (?P<salt>[./a-z0-9]{2})
        (?P<chk>([./a-z0-9]{11})+)?
        $c                    \        VR R4      pV P                  P                  V4      pV'       g    \        P                  P                  V 4      hVP                  RR4      w  r4V ! W4R7      # r?   r@   r.   rF   rC   r   r   r   r*   r+   r   r   rE   r@   r   r.   rF   s   &&   r   rG   bigcrypt.from_string  Y    $0OO!!$'&&))#..GGFE*	++r!   c                h    \        R 4      V P                  V P                  3,          p\        V4      # rJ   rK   rL   s   & r   rN   bigcrypt.to_string  rP   r!   c                   < \         \        V `  WR 7      p\        V4      ^,          '       d    \        P
                  P                  V 4      hV# ))relaxed)r   r   _norm_checksumr$   r*   r+   r   )rM   rD   r   r   s   &&&r   r   bigcrypt._norm_checksum  s@    477Rx=2&&))$//r!   c                *   \        V\        4      '       d   VP                  R 4      p\        WP                  P                  R4      4      p^p\        V4      pW48  d&   V^,           pV\        WV VRR 4      ,          pTpK+  VP                  R4      # )r#   r?   r   i)r&   r   r'   r2   r.   r$   rn   )rM   r   rF   r4   r5   r6   s   &&    r   rV   bigcrypt._calc_checksum  s    fg&&]]7+FVYY%5%5g%>?&ki7D>&T"2CBK@@CCzz'""r!   rp   )r.   )F)rv   rw   rx   ry   rz   r{   r|   r*   r}   r~   r   r   r   r   r   r	   r   r   r   r   rG   rN   r   rV   r   r   r   r   s   @@r   r   r     s     4 DL__N %&%MMJ
 **Q    ttBDDy	K , ,#
# 
#r!   c                      a  ] tR tRt o RtR tR	t^t]P                  t
^;tt]P                  t^t]P                   ! ]! R4      ]P$                  ]P&                  ,          4      t]R 4       tR tR tRtV tR# )
r   i  aD  This class implements the crypt16 password hash, and follows the :ref:`password-hash-api`.

It supports a fixed-length salt.

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 2 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

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

    .. versionadded:: 1.7

: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
zU
        ^
        (?P<salt>[./a-z0-9]{2})
        (?P<chk>[./a-z0-9]{22})?
        $c                    \        VR R4      pV P                  P                  V4      pV'       g    \        P                  P                  V 4      hVP                  RR4      w  r4V ! W4R7      # r   r   r   s   &&   r   rG   crypt16.from_string+  r   r!   c                h    \        R 4      V P                  V P                  3,          p\        V4      # rJ   rK   rL   s   & r   rN   crypt16.to_string4  rP   r!   c                2   \        V\        4      '       d   VP                  R 4      pV P                  '       d   V P	                  V4        \
        P                  ! V P                  P                  R4      4      p\        T4      p\        T^ T^4      p\        TR,          4      p\        T^ T^4      p\        P                  ! T4      \        P                  ! T4      ,           pTP                  R4      #   \         d    \        \        R4      4      hi ; i)r#   r?   zinvalid chars in salt:r      N)r&   r   r'   rR   rS   r   r%   r.   
ValueErrorr   r    r   r   r-   rn   )rM   r   r/   key1result1key2result2rF   s   &&      r   rV   crypt16._calc_checksum;  s    fg&&]]7+F ''/	F))$))*:*:7*CDJ
 $F+ (aR@ $F4L1 (aQ? !!'*V-@-@-IIzz'""#  	F ,C!DEE	Fs   /C6 6 Drp   Nrq   )rv   rw   rx   ry   rz   r{   r|   r   r*   r}   r~   r   r   r   r   r   r   r	   r   r   r   r   rG   rN   rV   r   r   r   s   @r   r   r     s     H D-L
 M__N
 %&%MMJ
 M
 **Q    ttBDDy	K , ,## #r!   )r   r   r   r   )*rz   r   logging	getLoggerrv   logwarningsr   passlib.utilsr   r   r   passlib.utils.binaryr   r   passlib.utils.compatr   r	   r
   r   r   passlib.crypto.desr   passlib.utils.handlersutilshandlersr*   __all__r)   r    r2   r8   r<   TruncateMixinHasManyBackendsHasSaltGenericHandlerr   	HasRoundsr   r   r   rp   r!   r   <module>r      s    L
 
 g''1  = < , [ [ 4 # # 
2'<
'6}Q  ""4"4bjj"BSBS }QF]_##R\\2::r?P?P ]_FM#rzz2,, M#fn#b

B,=,= n#r!   