o
    aĎiZ                     @  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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Zd-ddZ	d.d/d!d"Zd0d%d&Zd1d*d+ZdS )2    )annotationsN>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i@B c                 c  s$    | ]}|d ur|dkr|V  qd S )N/ .0sepr   r   M/home/jeff/fluffinator/venv/lib/python3.10/site-packages/werkzeug/security.py	<genexpr>   s    r
   z	list[str]_os_alt_sepsAUXCONzCONIN$zCONOUT$c                 c      | ]}d | V  qdS )COMNr   r   cr   r   r	   r
          u   123456789¹²³c                 c  r   )LPTNr   r   r   r   r	   r
      r   NULPRNlengthintreturnstrc                 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#   methodsaltpasswordtuple[str, str]c                 C  s8  |  d^} }| }| }| dkrS|sd}d}d}nz
tt|\}}}W n ty2   tdd w d| | | }	tj||||||	d d	| d| d| fS | d
krt|}
|
dkrdd}t	}n|
dkro|d }t	}n|
dkr~|d }t|d }ntdt
|||| d| d| fS td|  d)N:scrypti         z'scrypt' takes 3 arguments.   )r%   nrpmaxmemzscrypt: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&   args
salt_bytespassword_bytesr-   r.   r/   r0   len_args	hash_name
iterationsr   r   r	   _hash_internal$   sN   
rB   r)      salt_lengthc                 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#   rB   )r&   r$   rD   r%   hactual_methodr   r   r	   generate_password_hashT   s   "rH   pwhashboolc                 C  sD   z|  dd\}}}W n
 ty   Y dS w 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.
    rE   r3   Fr   )r4   r    hmaccompare_digestrB   )rI   r&   r$   r%   hashvalr   r   r	   check_password_hash{   s   rN   	directory	pathnames
str | Nonec                   s   | sd} | g}|D ]D  dkrt   t fddtD sEtjdkr1 dd   t	v sEtj
 sE dsE dksE d	rH d
S |  q	t j| S )a  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``.

    .. 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   c                 3  s    | ]}| v V  qd S r   r   r   filenamer   r	   r
      s    zsafe_join.<locals>.<genexpr>ntr   r   z..z../N)	posixpathnormpathanyr   osname	partitionstripupper_windows_device_filespathisabs
startswithappendr!   )rO   rP   partsr   rS   r	   	safe_join   s(   



rd   )r   r   r   r   )r$   r   r%   r   r&   r   r   r'   )r)   rC   )r&   r   r$   r   rD   r   r   r   )rI   r   r&   r   r   rJ   )rO   r   rP   r   r   rQ   )
__future__r   r7   rK   rY   rV   r   r   r:   listr   r_   altsepr   __annotations__r^   r#   rB   rH   rN   rd   r   r   r   r	   <module>   s<    

1
'