+
    i(U                     v   R t ^ RIt^ RIt]P                  ! ]4      t^ RIHtHtH	t	H
t
 ^ RIHt ^ RIHtHtHtHt ^ RIHu Ht RR.tRtRtRtRtRR lt]! R	4      t]! R
4      t]! R4      t ! R R]P>                  ]P@                  ]PB                  ]PD                  4      t# ! R R]#4      t$ ! R R]#4      t%R# )z9passlib.handlers.sha2_crypt - SHA256-Crypt / SHA512-CryptN)
safe_crypt
test_cryptrepeat_string
to_unicode)h64)byte_elem_valueuuascii_to_strunicodesha512_cryptsha256_crypt    c                   \        V \        4      '       d   V P                  R4      p \        V \        4      '       g   Q h\        V 9   d6   \
        P                  P                  V'       d   \        4      h\        4      h\        V 4      pRTu;8:  d   R8:  g   Q R4       h Q R4       h\        V\        4      '       g   Q R4       hVP                  R4      p\        V4      pV^8  g   Q R4       hV'       d   \        P                  p\        pM\        P                  p\        pV! W,           V ,           4      P!                  4       pV! W,           4      p	V	P"                  p
V
! \%        W4      4       TpV'       d%   T
! V^,          '       d   TMT 4       V^,          pK,  V	P!                  4       pV^`8  d(   \%        V! W,          4      P!                  4       V4      pMRV! V 4      pVP"                  pV^,
          pV'       d   V! V 4       V^,          pK  \%        VP!                  4       V4      p\        V4      V8X  g   Q hV! V^\'        V^ ,          4      ,           ,          4      P!                  4       RV p\        V4      V8X  g   Q R	4       hW,           pVV,           pVVVVV,           VV,           VV,           .p\(         UUu. uF  w  ppVV,          VV,          3NK  	  pppTp\+        V^*4      w  ppV'       dP   V F>  w  ppV! VV! VV,           4      P!                  4       ,           4      P!                  4       pK@  	  V^,          pKW  V'       d   V^,	          pVRV  F>  w  ppV! VV! VV,           4      P!                  4       ,           4      P!                  4       pK@  	  V^,          '       d,   V! VVV,          ^ ,          ,           4      P!                  4       p\,        P.                  ! VV4      P1                  R4      # u uppi )
a  perform raw sha256-crypt / sha512-crypt

this function provides a pure-python implementation of the internals
for the SHA256-Crypt and SHA512-Crypt algorithms; it doesn't
handle any of the parsing/validation of the hash strings themselves.

:arg pwd: password chars/bytes to hash
:arg salt: salt chars to use
:arg rounds: linear rounds cost
:arg use_512: use sha512-crypt instead of sha256-crypt mode

:returns:
    encoded checksum chars
zutf-8  ɚ;zinvalid roundszsalt not unicodeasciizsalt too largeNzsalt_len somehow > hash_len!)
isinstancer
   encodebytes_BNULLuhexcNullPasswordErrorr   r   lenhashlibsha512_512_transpose_mapsha256_256_transpose_mapdigestupdater   r   _c_digest_offsetsdivmodr   encode_transposed_bytesdecode)pwdsaltroundsuse_512pwd_lensalt_len
hash_consttranspose_mapdba_ctxa_ctx_updateidadptmp_ctxtmp_ctx_updatedsdp_dpdp_dspermsevenodddatadcblockstailpairss   &&&&                       Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/passlib/handlers/sha2_crypt.py_raw_sha2_cryptrA   8   sy   B #wjj!c5!!!!}ff&&w|QQLQQ#hG 6&Y&8(88&8(88& dG$$8&88$;;wD4yHb=***= ^^
*^^
*
 
CJ$	%	,	,	.B sz"E<<L r+, 	A
1q55Rc*	a 
B | :cm4;;=wG S/ AI3FA7>>+W5r7g
 
DBA!778	9	@	@	B9H	MBr7h> >>\ EErEEuRxB59E 9JJ8I94eDk5:&8IDJ 
B&"%LFD
ID#C*R$Y"7">">"@@AHHJB ! afuID#C*R$Y"7">">"@@AHHJB &
 !88BeQ/0779B
 &&r=9@@II3 Ks   P	zrounds=$0c                      a a ] tR t^t oRtRt]P                  t^t	]P                  t
RtRtRtRtRtRtRV 3R lltR tR	 t]R
 4       tR tRtRt]R 4       tR t]R 4       tR tRtVtV ;t# )_SHA2_CommonzBclass containing common code shared by sha256_crypt & sha512_cryptr   r   linearFNc                   < \         \        V `
  ! R/ VB  Vf$   V P                  ;'       d    V P                  R8H  pWn        R # )N   )superrE   __init__use_defaultsr'   implicit_rounds)selfrM   kwds	__class__s   &&,r@   rK   _SHA2_Common.__init__  s=    lD*2T2"#00HHT[[D5HO.    c                >    V P                  WP                  R J R7      # N)relaxed)
_norm_saltchecksum)rN   r&   s   &&r@   _parse_salt_SHA2_Common._parse_salt  s    t]]d-BCCrR   c                >    V P                  WP                  R J R7      # rT   )_norm_roundsrW   )rN   r'   s   &&r@   _parse_rounds_SHA2_Common._parse_rounds#  s      $1F GGrR   c                   \        VR R4      pV P                  pVP                  V4      '       g    \        P                  P                  V 4      h\        V4      ^8X  g   Q hVR,          P                  \        4      pV^ ,          P                  \        4      '       d   \        \        4      ^8X  g   Q hVP                  ^ 4      R,          pVP                  \        4      '       d+   V\        8w  d    \        P                  P                  V 4      h\        V4      pRpMRpRp\        V4      ^8X  d   Vw  rgM;\        V4      ^8X  d   V^ ,          pRpM\        P                  P                  V 4      hT ! TTT;'       g    RVR7      # )	r   hash:   NN:   NNFrH   TN)r'   r&   rW   rM   )r   ident
startswithr   r   InvalidHashErrorr   split_UDOLLAR_UROUNDSpop_UZEROZeroPaddedRoundsErrorintMalformedHashError)clsr_   rb   partsr'   rM   r&   chks   &&      r@   from_string_SHA2_Common.from_string'  sF    $0		u%%&&))#..5zQRx( 8x((x=A%%%YYq\"%F  ((Vv-=ff22377[F#OF"O u:?ID#Z1_8DC&&++C00 [[D+	 	rR   c                   V P                   R 8X  dZ   V P                  '       dH   \        R4      V P                  V P                  V P
                  ;'       g    \        R4      3,          pMQ\        R4      V P                  V P                   V P                  V P
                  ;'       g    \        R4      3,          p\        V4      # )rH   z%s%s$%s z%srounds=%d$%s$%s)r'   rM   r   rb   r&   rW   r	   )rN   r_   s   & r@   	to_string_SHA2_Common.to_stringT  s    ;;$4#7#7#7Y<4::tyy#'==#9#9AbE#; ;D ()TZZ-1YY8N8N2-P PDT""rR   c                r    \        V P                  !  '       d   V P                  V P                  4       R # R# )TF)r   
_test_hash_set_calc_checksum_backend_calc_checksum_os_cryptrm   s   &r@   _load_backend_os_crypt#_SHA2_Common._load_backend_os_crypti  s+    s~~&&**3+F+FGrR   c                8   V P                  4       p\        W4      pVf   V P                  V4      # V P                  pVP	                  V P
                  4      '       d   W4) ^,
          ,          \        8w  d!   \        P                  P                  WV4      hW4) R  # N)
rt   r   _calc_checksum_builtinchecksum_sizerc   rb   rf   r   r   CryptBackendError)rN   secretconfigr_   css   &&   r@   ry   $_SHA2_Common._calc_checksum_os_cryptq  s    !&)< ..v66 tzz**d3q5kX.E&&**4>>CDzrR   c                <    V P                  V P                  4       R # )T)rx   r   rz   s   &r@   _load_backend_builtin"_SHA2_Common._load_backend_builtin  s    &&s'A'ABrR   c                X    \        WP                  V P                  V P                  4      # r~   )rA   r&   r'   _cdb_use_512)rN   r   s   &&r@   r   #_SHA2_Common._calc_checksum_builtin  s$    vyy$++#002 	2rR   )rM   )r&   r'   rM   	salt_sizer~   )os_cryptbuiltin) __name__
__module____qualname____firstlineno____doc__setting_kwdsr   HASH64_CHARSchecksum_charsmax_salt_size
salt_chars
min_rounds
max_roundsrounds_costr   _rounds_prefixrM   rK   rX   r\   classmethodrp   rt   backendsrw   r{   ry   r   r   __static_attributes____classdictcell____classcell__)rP   __classdict__s   @@r@   rE   rE      s     L
 FL__N MJJJKLN
 O/DH * *X# 'H J "  2 2rR   rE   c                   :    ] tR tRtRtR t]! R4      t^+tRt	Rt
RtR# )r   i  a  This class implements the SHA256-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, one will be autogenerated (this is recommended).
    If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 535000, must be between 1000 and 999999999, inclusive.

    .. note::
        per the official specification, when the rounds parameter is set to 5000,
        it may be omitted from the hash string.

: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

..
    commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

    :type implicit_rounds: bool
    :param implicit_rounds:
        this is an internal option which generally doesn't need to be touched.

        this flag determines whether the hash should omit the rounds parameter
        when encoding it to a string; this is only permitted by the spec for rounds=5000,
        and the flag is ignored otherwise. the spec requires the two different
        encodings be preserved as they are, instead of normalizing them.
z$5$i) rI   N)testz?$5$rounds=1000$test$QmQADEXMG8POI5WDsaeho0P36yK3Tcrgboabng6bkb/)r   r   r   r   r   namer   rb   r   default_roundsrw   r   rI   rR   r@   r   r     s)    *\ DeHEMN
:JrR   c                   >    ] tR tRtRtR t]! R4      t^VtRt	Rt
RtRtR# )	r   i  a  This class implements the SHA512-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, one will be autogenerated (this is recommended).
    If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 656000, must be between 1000 and 999999999, inclusive.

    .. note::
        per the official specification, when the rounds parameter is set to 5000,
        it may be omitted from the hash string.

: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

..
    commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

    :type implicit_rounds: bool
    :param implicit_rounds:
        this is an internal option which generally doesn't need to be touched.

        this flag determines whether the hash should omit the rounds parameter
        when encoding it to a string; this is only permitted by the spec for rounds=5000,
        and the flag is ignored otherwise. the spec requires the two different
        encodings be preserved as they are, instead of normalizing them.
z$6$Ti
 rI   N)r   zj$6$rounds=1000$test$2M/Lx6MtobqjLjobw0Wmo4Q5OFx5nVLJvmgseatA6oMnyWeBdRDx4DU.1H3eGmse6pgsOgDisWBGI5c7TZauS0)r   r   r   r   r   r   r   rb   r   r   r   rw   r   rI   rR   r@   r   r     s.    *^ DeHEMLN
(JrR   ))    r`         r   r`   )r      r   r   r   r`   )   r   r   r   )r   r   r   r   r   )r   r`   r   r   )r   r   r   r   r   )    
   r      r      r               r`      r      r                     ra                     	         )@*   r   r   r   +   r   r   r   ,   -   r   r`   r   .   r   r   r   /   0   r   r   ra   1   r   r   r   2   3   r   r   r   4   r       r   5   6   !   r   r   7   "   #   r   8   9   $   r   r   :   %   &   r   ;   <   '   r   r   =   (   )   r   >   ?   )F)&r   r   logging	getLoggerr   logpasslib.utilsr   r   r   r   passlib.utils.binaryr   passlib.utils.compatr   r   r	   r
   passlib.utils.handlersutilshandlersr   __all__r   r!   r   r   rA   rg   rf   ri   HasManyBackends	HasRoundsHasSaltGenericHandlerrE   r   r   rI   rR   r@   <module>r      s    ?
  g''14 4 $8 8 # #  
   |JB Y<S6	
3L22%%r||RZZ$$L2d9:< 9:D=(< =(rR   