1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
U
Þ=®d¶ã@sÌUddlmZddlZddlZddlZddlZddlZddlZdZdZ    e
dd„ej ej j fDƒƒZded<d    d
d œd d „Zd
d
d
ddœdd„Zdd
d
d    d
dœdd„Zd
d
ddœdd„Zd
d
ddœdd„ZdS) é)Ú annotationsNZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789iÀ'    ccs"|]}|dk    r|dkr|VqdS)Nú/©©Ú.0ÚseprrúHd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/security.pyÚ    <genexpr> sr    z    list[str]Ú _os_alt_sepsÚintÚstr)ÚlengthÚreturncCs(|dkrtdƒ‚d dd„t|ƒDƒ¡S)zAGenerate a random string of SALT_CHARS with specified ``length``.rzSalt length must be at least 1.Úcss|]}t t¡VqdS©N)ÚsecretsÚchoiceÚ
SALT_CHARS)rÚ_rrrr    szgen_salt.<locals>.<genexpr>)Ú
ValueErrorÚjoinÚrange)r rrrÚgen_saltsrztuple[str, str])ÚmethodÚsaltÚpasswordrc Cs†|dkrtjddd||fS| d¡^}}| d¡}| d¡}|dkrÎ|sZd}d    }d
}n4ztt|ƒ\}}}Wntk
rŒtd ƒd‚YnXd |||}tj||||||d      ¡d|›d|›d|›fS|dkrVt
|ƒ}|dkròd}    t }
n@|d
kr
|d}    t }
n(|dkr*|d}    t|d
ƒ}
ntdƒ‚t  |    |||
¡     ¡d|    ›d|
›fStjd|›dddt  |||¡ ¡|fSdS)NÚplainznThe 'plain' password method is deprecated and will be removed in Werkzeug 3.0. Migrate to the 'scrypt' method.é)Ú
stacklevelú:zutf-8Úscrypti€ééz'scrypt' takes 3 arguments.é„)rÚnÚrÚpÚmaxmemzscrypt:Úpbkdf2rÚsha256éz'pbkdf2' takes 2 arguments.zpbkdf2:zThe 'zd' password method is deprecated and will be removed in Werkzeug 3.0. Migrate to the 'scrypt' method.)ÚwarningsÚwarnÚsplitÚencodeÚmapr rÚhashlibr ÚhexÚlenÚDEFAULT_PBKDF2_ITERATIONSÚ pbkdf2_hmacÚhmacÚnewÚ    hexdigest) rrrÚargsr$r%r&r'Zlen_argsÚ    hash_nameZ
iterationsrrrÚ_hash_internalsTý
 
þ
 
 
þ
ýr:r(é)rrÚ salt_lengthrcCs,t|ƒ}t|||ƒ\}}|›d|›d|›S)aSecurely 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``, more secure but not available on PyPy. The parameters are ``n``,
        ``r``, and ``p``, the default is ``scrypt:32768:8:1``. See
        :func:`hashlib.scrypt`.
    -   ``pbkdf2``, the default. 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:: 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.
    ú$)rr:)rrr<rÚhZ actual_methodrrrÚgenerate_password_hashSs r?Úbool)ÚpwhashrrcCsFz| dd¡\}}}Wntk
r,YdSXt t|||ƒd|¡S)aASecurely 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-rr5Úcompare_digestr:)rArrrZhashvalrrrÚcheck_password_hashxs
rCz
str | None)Ú    directoryÚ    pathnamesrcsx|sd}|g}|D]Z‰ˆdkr(t ˆ¡‰t‡fdd„tDƒƒs\tj ˆ¡s\ˆdks\ˆ d¡rbdS| ˆ¡qtj    |ŽS)a2Safely 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``.
    Ú.rc3s|]}|ˆkVqdSrrr©Úfilenamerrr    £szsafe_join.<locals>.<genexpr>z..z../N)
Ú    posixpathÚnormpathÚanyr
ÚosÚpathÚisabsÚ
startswithÚappendr)rDrEÚpartsrrGrÚ    safe_joinŽs"    
ÿ
þýü rR)r(r;)Ú
__future__rr0r5rLrIrr+rr3ÚlistrrMÚaltsepr
Ú__annotations__rr:r?rCrRrrrrÚ<module>s&  ÿ:ÿ%