
    2Bf                     B   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d dlZej                  r	 dZ	dZ
 ed ej                  j                  ej                  j                  fD              Zej                   e   ed<   e
ddfdej&                  eef   dej&                  eef   ded	ej,                  e   d
ej,                  ej&                  eej.                  f      defdZe
ddfdej&                  eef   dej&                  eef   ded	ej,                  e   d
ej,                  ej&                  eej.                  f      defdZdededefdZ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!y)    N>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i c              #   2   K   | ]  }||dk7  s|  y w)N/ ).0seps     Q/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/werkzeug/security.py	<genexpr>r
      s      !COs
C!s   _os_alt_sepsdatasalt
iterationskeylenhashfuncreturnc                 t    t        j                  dt        d       t        | ||||      j	                         S )a  Like :func:`pbkdf2_bin`, but returns a hex-encoded string.

    :param data: the data to derive.
    :param salt: the salt for the derivation.
    :param iterations: the number of iterations.
    :param keylen: the length of the resulting key.  If not provided,
                   the digest size will be used.
    :param hashfunc: the hash function to use.  This can either be the
                     string name of a known hash function, or a function
                     from the hashlib module.  Defaults to sha256.

    .. deprecated:: 2.0
        Will be removed in Werkzeug 2.1. Use :func:`hashlib.pbkdf2_hmac`
        instead.

    .. versionadded:: 0.9
    zj'pbkdf2_hex' is deprecated and will be removed in Werkzeug 2.1. Use 'hashlib.pbkdf2_hmac().hex()' instead.   
stacklevel)warningswarnDeprecationWarning
pbkdf2_binhex)r   r   r   r   r   s        r	   
pbkdf2_hexr      s9    0 MM	;	 dD*fh?CCEE    c                 8   t        j                  dt        d       t        | t              r| j                  d      } t        |t              r|j                  d      }|sd}nt        |      r |       j                  }n|}t        j                  || |||      S )ae  Returns a binary digest for the PBKDF2 hash algorithm of `data`
    with the given `salt`. It iterates `iterations` times and produces a
    key of `keylen` bytes. By default, SHA-256 is used as hash function;
    a different hashlib `hashfunc` can be provided.

    :param data: the data to derive.
    :param salt: the salt for the derivation.
    :param iterations: the number of iterations.
    :param keylen: the length of the resulting key.  If not provided
                   the digest size will be used.
    :param hashfunc: the hash function to use.  This can either be the
                     string name of a known hash function or a function
                     from the hashlib module.  Defaults to sha256.

    .. deprecated:: 2.0
        Will be removed in Werkzeug 2.1. Use :func:`hashlib.pbkdf2_hmac`
        instead.

    .. versionadded:: 0.9
    zd'pbkdf2_bin' is deprecated and will be removed in Werkzeug 2.1. Use 'hashlib.pbkdf2_hmac()' instead.r   r   utf8sha256)
r   r   r   
isinstancestrencodecallablenamehashlibpbkdf2_hmac)r   r   r   r   r   	hash_names         r	   r   r   5   s    6 MM	5	 ${{6"${{6"		(	JOO		y$j&IIr   abc                     t        j                  dt        d       t        | t              r| j                  d      } t        |t              r|j                  d      }t        j                  | |      S )ai  This function compares strings in somewhat constant time.  This
    requires that the length of at least one string is known in advance.

    Returns `True` if the two strings are equal, or `False` if they are not.

    .. deprecated:: 2.0
        Will be removed in Werkzeug 2.1. Use
        :func:`hmac.compare_digest` instead.

    .. versionadded:: 0.7
    zd'safe_str_cmp' is deprecated and will be removed in Werkzeug 2.1. Use 'hmac.compare_digest' instead.r   r   utf-8)r   r   r   r    r!   r"   hmaccompare_digest)r(   r)   s     r	   safe_str_cmpr.   g   s`     MM	3	 !SHHW!SHHWq!$$r   lengthc                 d    | dk  rt        d      dj                  d t        |       D              S )zAGenerate a random string of SALT_CHARS with specified ``length``.r   zSalt length must be positive c              3   N   K   | ]  }t        j                  t                y wN)secretschoice
SALT_CHARS)r   _s     r	   r
   zgen_salt.<locals>.<genexpr>   s     E!7>>*-Es   #%)
ValueErrorjoinrange)r/   s    r	   gen_saltr;      s.    {78877EuV}EEEr   methodpasswordc                 <   | dk(  r|| fS |j                  d      }|j                  d      }| j                  d      r|st        d      | dd j                  d      }t	        |      dvrt        d	      |j                  d
      } |rt        |d
   xs d
      nt        }t        j                  | |||      j                         d|  d| fS |r't        j                  |||       j                         | fS t        j                  | |      j                         | fS )zInternal password hash helper.  Supports plaintext without salt,
    unsalted and salted passwords.  In case salted passwords are used
    hmac is used.
    plainr+   zpbkdf2:zSalt is required for PBKDF2   N:)   r   z&Invalid number of arguments for PBKDF2r   )r"   
startswithr8   splitlenpopintDEFAULT_PBKDF2_ITERATIONSr%   r&   r   r,   new	hexdigest)r<   r   r=   argsr   s        r	   _hash_internalrL      s   
 ;;wDw'H#:;;abz$t9F"EFF!*.SaA&4M
$
CGGIfXQzl+
 	

 xxh/99;VCC;;vx(224f<<r   salt_lengthc                 Z    |dk7  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?   r1   $)r;   rL   )r=   r<   rM   r   hactual_methods         r	   generate_password_hashrR      sA    6 %+g$58K 2D%fdH=A}_AdV1QC((r   pwhashc                     | j                  d      dk  ry| j                  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.
    rO   r   Fr   )countrD   r,   r-   rL   )rS   r=   r<   r   hashvals        r	   check_password_hashrW      sP     ||C1"LLa0FD'~fdHEaH'RRr   	directory	pathnamesc                 0   | g}|D ]|  dk7  rt        j                        t        fdt        D              s5t        j
                  j                        sdk(  sj                  d      r y|j                         ~ 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``.
    r1   c              3   &   K   | ]  }|v  
 y wr3   r   )r   r   filenames     r	   r
   zsafe_join.<locals>.<genexpr>   s     8Cx8s   z..z../N)
	posixpathnormpathanyr   ospathisabsrC   appendr9   )rX   rY   partsr\   s      @r	   	safe_joinre      s     KE r> ))(3H 8<88ww}}X&4""5)X >>5!!r   )zpbkdf2:sha256   )"r%   r,   r`   r]   r4   typingtr   TYPE_CHECKINGr6   rH   listra   r   altsepr   Listr!   __annotations__UnionbytesrG   OptionalCallabler   r   boolr.   r;   TuplerL   rR   rW   re   r   r   r	   <module>rt      sN     	    ??M
"   !GGKK0! affSk  0"59F
''#u*
F
''#u*
F F JJsO	F
 jjajj12F 	FH 0"59/J
''#u*
/J
''#u*
/J /J JJsO	/J
 jjajj12/J /Jd%C %C %D %8FS FS F=3 =c =S =QWWS#X=N =D FH)))?B))@S Ss St S$" "# "!**S/ "r   