/usr/local/lib/python3.6/site-packages/werkzeug/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/werkzeug/__pycache__/security.cpython-36.pyc (8040B)
3
_TBg @ s U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZejr@dZ dZ
edd ejj
ejjgD Zeje e
ddfejeef ejeef eeje ejejeejf edddZe
ddfejeef ejeef eeje ejejeejf edd d
Zeeeddd
ZeedddZeeeejeef dddZdeeeedddZeeedddZeeeje dddZ dS ) NZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i c c s" | ]}|d k r|dkr|V qd S )N/ ).0sepr r 5/tmp/pip-build-0s3hx122/Werkzeug/werkzeug/security.py
s r )datasalt
iterationskeylenhashfuncreturnc C s$ t jdtdd 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)warningswarnDeprecationWarning
pbkdf2_binhex)r r r
r r r r r
pbkdf2_hex s
r c C sj t jdtdd t| tr$| jd} t|tr8|jd}|sBd}nt|rT| j}n|}tj || |||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 utf8sha256)
r r r
isinstancestrencodecallablenamehashlibpbkdf2_hmac)r r r
r r hash_namer r r r 5 s
r )abr
c C sD t jdtdd t| tr$| jd} t|tr8|jd}tj| |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 zutf-8)r r r r r r hmaccompare_digest)r r! r r r safe_str_cmpg s
r$ )lengthr
c C s( | dkrt ddjdd t| D S )zAGenerate a random string of SALT_CHARS with specified ``length``.r zSalt length must be positive c s s | ]}t jtV qd S )N)secretschoice
SALT_CHARS)r _r r r r s zgen_salt..)
ValueErrorjoinrange)r% r r r gen_salt s r. )methodr passwordr
c C s | dkr|| fS |j d}|j d}| jdr|s:td| dd jd}t|dkr`td
|jd} |r~t|d pzdnt}tj | |||j
d| d| fS |rtj||| j
| fS tj| |j
| fS )
zInternal password hash helper. Supports plaintext without salt,
unsalted and salted passwords. In case salted passwords are used
hmac is used.
plainzutf-8zpbkdf2:zSalt is required for PBKDF2 N: r z&Invalid number of arguments for PBKDF2r )r4 r )r
startswithr+ splitlenpopintDEFAULT_PBKDF2_ITERATIONSr r r r" new hexdigest)r/ r r0 argsr
r r r _hash_internal s"
r>
pbkdf2:sha256 )r0 r/ salt_lengthr
c C s8 |dkrt |nd}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.
r1 r&