
    d-              
       X   U d dl Z d dlZd dlZd dlZd dlZd dlZej        r	 dZdZ	 e
d ej        ej        j        fD                       Zej        e         ed<   dedefdZd	ed
ededej        eef         fdZ	 dded	ededefdZdededefdZdededej        e         fdZdS )    N>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i c              #   *   K   | ]}||dk    
|V  d S )N/ ).0seps     1lib/python3.11/site-packages/werkzeug/security.py	<genexpr>r
      sG       ! !s!CF#:!! ! ! ! ! !    _os_alt_sepslengthreturnc                     | dk    rt          d          d                    d t          |           D                       S )zAGenerate a random string of SALT_CHARS with specified ``length``.r   zSalt length must be positive c              3   H   K   | ]}t          j        t                    V  d S N)secretschoice
SALT_CHARS)r   _s     r	   r
   zgen_salt.<locals>.<genexpr>   s,      EE!7>*--EEEEEEr   )
ValueErrorjoinrange)r   s    r	   gen_saltr      sD    { 9788877EEuV}}EEEEEEr   methodsaltpasswordc                    | dk    r|| fS |                     d          }|                     d          }|                     d          r|st          d          | dd                             d          }t	          |          dvrt          d	          |                    d
          } |rt          |d
         pd
          nt          }t          j	        | |||          
                                d|  d| fS |r*t          j        |||                                           | fS t          j        | |                                          | fS )zInternal password hash helper.  Supports plaintext without salt,
    unsalted and salted passwords.  In case salted passwords are used
    hmac is used.
    plainzutf-8zpbkdf2:zSalt is required for PBKDF2   N:)      z&Invalid number of arguments for PBKDF2r   )encode
startswithr   splitlenpopintDEFAULT_PBKDF2_ITERATIONShashlibpbkdf2_hmachexhmacnew	hexdigest)r   r   r   args
iterationss        r	   _hash_internalr3      sh   
   ;;wDw''H## 
 	<:;;;abbz$$t99F" 	GEFFF!*.MSaA&&&4M
$
CCGGII+f++z++
 	

  Dxh//99;;VCC;vx((2244f<<r   pbkdf2:sha256   salt_lengthc                 l    |dk    rt          |          nd}t          |||           \  }}| d| d| S )a  Hash a password with the given method and salt with a string of
    the given length. The format of the string returned includes the method
    that was used so that :func:`check_password_hash` can check the hash.

    The format for the hashed string looks like this::

        method$salt$hash

    This method can **not** generate unsalted passwords but it is possible
    to set param method='plain' in order to enforce plaintext passwords.
    If a salt is used, hmac is used internally to salt the password.

    If PBKDF2 is wanted it can be enabled by setting the method to
    ``pbkdf2:method:iterations`` where iterations is optional::

        pbkdf2:sha256:80000$salt$hash
        pbkdf2:sha256$salt$hash

    :param password: the password to hash.
    :param method: the hash method to use (one that hashlib supports). Can
                   optionally be in the format ``pbkdf2:method:iterations``
                   to enable PBKDF2.
    :param salt_length: the length of the salt in letters.
    r   r   $)r   r3   )r   r   r6   r   hactual_methods         r	   generate_password_hashr;   <   sR    6 %+g$5=8K   2D%fdH==A}((d((Q(((r   pwhashc                     |                      d          dk     rdS |                     dd          \  }}}t          j        t	          |||          d         |          S )a  Check a password against a given salted and hashed password value.
    In order to support unsalted legacy passwords this method supports
    plain text passwords, md5 and sha1 hashes (both salted and unsalted).

    Returns `True` if the password matched, `False` otherwise.

    :param pwhash: a hashed string like returned by
                   :func:`generate_password_hash`.
    :param password: the plaintext password to compare against the hash.
    r8   r#   Fr   )countr&   r.   compare_digestr3   )r<   r   r   r   hashvals        r	   check_password_hashrA   \   s`     ||C1 u"LLa00FD'~fdHEEaH'RRRr   	directory	pathnamesc                 P   | sd} | g}|D ]dk    rt          j                  t          fdt          D                       s:t          j                                      sdk    s                    d          r dS |                               t          j	        | S )a2  Safely join zero or more untrusted path components to a base
    directory to avoid escaping the base directory.

    :param directory: The trusted base directory.
    :param pathnames: The untrusted path components relative to the
        base directory.
    :return: A safe path, otherwise ``None``.
    .r   c              3       K   | ]}|v V  	d S r   r   )r   r   filenames     r	   r
   zsafe_join.<locals>.<genexpr>   s'      88Cx888888r   z..z../N)
	posixpathnormpathanyr   ospathisabsr%   appendr   )rB   rC   partsrG   s      @r	   	safe_joinrP   n   s       	KE  r> 	4 )(33H 8888<88888	w}}X&&	 4	 ""5))		 44X>5!!r   )r4   r5   )r+   r.   rK   rH   r   typingtTYPE_CHECKINGr   r*   listr   rL   altsepr   Liststr__annotations__r)   r   Tupler3   r;   boolrA   OptionalrP   r   r   r	   <module>r\      s     				         ? 	M
"  D ! !FBGN+! ! !  afSk   
FS FS F F F F=3 =c =S =QWS#X=N = = = =D FH) )))?B)) ) ) )@S Ss St S S S S$" "# "!*S/ " " " " " "r   