a
    é´«jþ  ã                   @  sò   U d dl mZ d dlZd dlZd dlZd dlZd dlZdZdZe	dd„ ej
ejfD ƒƒZded< d	d
ddhdd„ dD ƒ£dd„ dD ƒ£d’d’Zdddœdd„Zdddddœdd„Zd(dddddœdd„Zddd d!œd"d#„Zddd$d%œd&d'„ZdS ))é    )ÚannotationsNZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i@B c                 c  s"   | ]}|d ur|dkr|V  qd S )Nú/© ©Ú.0Úsepr   r   úP/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/werkzeug/security.pyÚ	<genexpr>   s   r	   z	list[str]Ú_os_alt_sepsÚAUXÚCONzCONIN$zCONOUT$c                 c  s   | ]}d |› �V  qdS )ZCOMNr   ©r   Úcr   r   r   r	      ó    u   123456789Â¹Â²Â³c                 c  s   | ]}d |› �V  qdS )ZLPTNr   r   r   r   r   r	      r   ÚNULÚPRNÚintÚstr)ÚlengthÚreturnc                 C  s(   | dkrt dƒ‚d dd„ t| ƒD ƒ¡S )zAGenerate a random string of SALT_CHARS with specified ``length``.r   zSalt length must be at least 1.Ú c                 s  s   | ]}t  t¡V  qd S ©N)ÚsecretsÚchoiceÚ
SALT_CHARS)r   Ú_r   r   r   r	   !   r   zgen_salt.<locals>.<genexpr>)Ú
ValueErrorÚjoinÚrange)r   r   r   r   Úgen_salt   s    r   ztuple[str, str])ÚmethodÚsaltÚpasswordr   c                 C  sD  |   d¡^} }| ¡ }| ¡ }| dkrª|s8d}d}d}n2ztt|ƒ\}}}W n tyh   tdƒd ‚Y n0 d| | | }	tj||||||	d� ¡ d	|› d|› d|› �fS | d
k�r0t|ƒ}
|
dkrÎd}t	}n>|
dkrä|d }t	}n(|
dk�r|d }t|d ƒ}ntdƒ‚t 
||||¡ ¡ d|› d|› �fS td| › d�ƒ‚d S )Nú:Úscrypti €  é   é   z'scrypt' takes 3 arguments.é„   )r!   ÚnÚrÚpÚmaxmemzscrypt:Zpbkdf2r   Úsha256é   z'pbkdf2' takes 2 arguments.zpbkdf2:zInvalid hash method 'z'.)ÚsplitÚencodeÚmapr   r   Úhashlibr$   ÚhexÚlenÚDEFAULT_PBKDF2_ITERATIONSÚpbkdf2_hmac)r    r!   r"   ÚargsZ
salt_bytesZpassword_bytesr(   r)   r*   r+   Zlen_argsÚ	hash_nameZ
iterationsr   r   r   Ú_hash_internal$   sH    ÿü

ÿür8   r$   é   )r"   r    Úsalt_lengthr   c                 C  s,   t |ƒ}t||| ƒ\}}|› d|› d|› �S )aD  Securely hash a password for storage. A password can be compared to a stored hash
    using :func:`check_password_hash`.

    The following methods are supported:

    -   ``scrypt``, the default. The parameters are ``n``, ``r``, and ``p``, the default
        is ``scrypt:32768:8:1``. See :func:`hashlib.scrypt`.
    -   ``pbkdf2``, less secure. The parameters are ``hash_method`` and ``iterations``,
        the default is ``pbkdf2:sha256:600000``. See :func:`hashlib.pbkdf2_hmac`.

    Default parameters may be updated to reflect current guidelines, and methods may be
    deprecated and removed if they are no longer considered secure. To migrate old
    hashes, you may generate a new hash when checking an old hash, or you may contact
    users with a link to reset their password.

    :param password: The plaintext password.
    :param method: The key derivation function and parameters.
    :param salt_length: The number of characters to generate for the salt.

    .. versionchanged:: 3.1
        The default iterations for pbkdf2 was increased to 1,000,000.

    .. versionchanged:: 2.3
        Scrypt support was added.

    .. versionchanged:: 2.3
        The default iterations for pbkdf2 was increased to 600,000.

    .. versionchanged:: 2.3
        All plain hashes are deprecated and will not be supported in Werkzeug 3.0.
    ú$)r   r8   )r"   r    r:   r!   ÚhZactual_methodr   r   r   Úgenerate_password_hashT   s    "r=   Úbool)Úpwhashr"   r   c                 C  sD   z|   dd¡\}}}W n ty*   Y dS 0 t t|||ƒd |¡S )aA  Securely check that the given stored password hash, previously generated using
    :func:`generate_password_hash`, matches the given password.

    Methods may be deprecated and removed if they are no longer considered secure. To
    migrate old hashes, you may generate a new hash when checking an old hash, or you
    may contact users with a link to reset their password.

    :param pwhash: The hashed password.
    :param password: The plaintext password.

    .. versionchanged:: 2.3
        All plain hashes are deprecated and will not be supported in Werkzeug 3.0.
    r;   r-   Fr   )r.   r   ÚhmacÚcompare_digestr8   )r?   r"   r    r!   Zhashvalr   r   r   Úcheck_password_hash{   s
    rB   z
str | None)Ú	directoryÚ	untrustedr   c                   s¢   | sd} | g}|D ]„‰ ˆ sqt  ˆ ¡‰ tj ˆ ¡s†ˆ  d¡s†ˆ dks†ˆ  d¡s†t‡ fdd„tD ƒƒs†tjdkrŒtdd„ ˆ  	d¡D ƒƒrŒ d	S | 
ˆ ¡ qt j|Ž S )
aœ  Safely join zero or more untrusted path components to a trusted base
    directory to avoid escaping the base directory.

    The untrusted path is assumed to be from/for a URL, such as for serving
    files. Therefore, it should only use the forward slash ``/`` path separator,
    and will be joined using that separator. On Windows, the backslash ``\``
    separator is not allowed.

    :param directory: The trusted base directory.
    :param untrusted: The untrusted path components relative to the
        base directory.
    :return: A safe path, otherwise ``None``.

    .. versionchanged:: 3.1.6
        Special device names in multi-segment paths are not allowed on Windows.

    .. versionchanged:: 3.1.5
        More special device names, regardless of extension or trailing spaces,
        are not allowed on Windows.

    .. versionchanged:: 3.1.4
        Special device names are not allowed on Windows.
    Ú.r   z..z../c                 3  s   | ]}|ˆ v V  qd S r   r   r   ©Úpartr   r   r	   ¼   r   zsafe_join.<locals>.<genexpr>Úntc                 s  s(   | ] }|  d ¡d  ¡  ¡ tv V  qdS )rE   r   N)Ú	partitionÚstripÚupperÚ_windows_device_files)r   r*   r   r   r   r	   ¿   s   ÿN)Ú	posixpathÚnormpathÚosÚpathÚisabsÚ
startswithÚanyr
   Únamer.   Úappendr   )rC   rD   Úpartsr   rF   r   Ú	safe_join‘   s4    

ÿýüûúø	þ÷rW   )r$   r9   )Ú
__future__r   r1   r@   rO   rM   r   r   r4   Úlistr   Úaltsepr
   Ú__annotations__rL   r   r8   r=   rB   rW   r   r   r   r   Ú<module>   s:   
ÿüûúùø1 ÿ'