Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/werkzeug/__pycache__/security.cpython-37.pyc

125 lines
7.7 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<5D><00>@s,dZddlZddlZddlZddlZddlZddlmZddlm Z ddl
m Z ddl
m Z ddl
m Z dd l
mZdd
l
mZdd l
mZd Zd Ze d<0E>jZeedd<02>Ze<07>Zedd<11>ejjejjgD<00><01>Zeddfdd<13>Zeddfdd<15>Zdd<17>Zdd<19>Z dd<1B>Z!dd<1D>Z"d&d d!<21>Z#d"d#<23>Z$d$d%<25>Z%dS)'z<>
werkzeug.security
~~~~~~~~~~~~~~~~~
Security related helpers such as secure password hashing tools.
:copyright: 2007 Pallets
:license: BSD-3-Clause
<EFBFBD>N)<01> SystemRandom)<01>Struct<63>)<01>izip)<01>PY2)<01>
range_type)<01> text_type)<01>to_bytes)<01> to_nativeZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789i<39>Iz>I<>compare_digestccs|]}|dkr|VqdS))N<>/N<>)<02>.0<EFBFBD>sepr r <00>7/tmp/pip-install-c3kgu56x/Werkzeug/werkzeug/security.py<70> <genexpr>!srcCs t|||||<04>}tt<02>|d<01><02>S)a)Like :func:`pbkdf2_bin`, but returns a hex-encoded string.
.. versionadded:: 0.9
: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.
<20> hex_codec)<04>
pbkdf2_binr
<00>codecs<63>encode)<06>data<74>salt<6C>
iterations<EFBFBD>keylen<65>hashfunc<6E>rvr r r<00>
pbkdf2_hex%srcCsJ|sd}t|<00>}t|<01>}t|<04>r4|<04>}t|dd<03>}n|}t<03>|||||<03>S)a<>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.
.. versionadded:: 0.9
: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.
<20>sha256<35>nameN)r <00>callable<6C>getattr<74>hashlib<69> pbkdf2_hmac)rrrrrZ
_test_hash<EFBFBD> hash_namer r rr9srcCs<>t|t<01>r|<00>d<01>}t|t<01>r(|<01>d<01>}tdk r:t||<01>St|<00>t|<01>krNdSd}tr<>xPt||<01>D]\}}|t|<03>t|<04>AO}qbWn$x"t||<01>D]\}}|||AO}q<>W|dkS)z<>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.
.. versionadded:: 0.7
zutf-8NFr)<08>
isinstancerr<00>_builtin_safe_str_cmp<6D>lenrr<00>ord)<05>a<>br<00>x<>yr r r<00> safe_str_cmpZs




r,cCs(|dkrtd<02><01>d<03>dd<05>t|<00>D<00><01>S)zAGenerate a random string of SALT_CHARS with specified ``length``.rzSalt length must be positive<76>css|]}t<00>t<02>VqdS)N)<03>_sys_rng<6E>choice<63>
SALT_CHARS)r<00>_r r rr|szgen_salt.<locals>.<genexpr>)<03>
ValueError<EFBFBD>joinr)<01>lengthr r r<00>gen_saltxsr5c Cs<>|dkr||fSt|t<01>r$|<02>d<02>}|<00>d<03>r<>|dd<05><00>d<06>}t|<03>dkrTtd<08><01>|<03>d <09>}|rrt|d pnd <09>ptt }d
}d ||f}nd }|}|r<>|s<>td <0A><01>t
||||d<0E>}n>|r<>t|t<01>r<>|<01>d<02>}t |||<00>}|<08> <0C>}nt <0A>||<02><02> <0C>}||fS)z<>Internal password hash helper. Supports plaintext without salt,
unsalted and salted passwords. In case salted passwords are used
hmac is used.
<20>plainzutf-8zpbkdf2:<3A>N<>:)r<00>z&Invalid number of arguments for PBKDF2rTz pbkdf2:%s:%dFzSalt is required for PBKDF2)r)r$rr<00>
startswith<EFBFBD>splitr&r2<00>pop<6F>int<6E>DEFAULT_PBKDF2_ITERATIONSr<00> _create_mac<61> hexdigestr!<00>new) <09>methodr<00>password<72>argsrZ is_pbkdf2<66> actual_methodr<00>macr r r<00>_hash_internals2


 


 
rGcs8t<00><00>rt<01>||<01><00>Sd<04>fdd<03> }||_t<01>|||<03>S)N<>cs t<00><01>|<00>S)N)r!rA)<01>d)rBr rr<00>sz_create_mac.<locals>.hashfunc)rH)r<00>hmac<61>HMAC<41>__call__)<04>key<65>msgrBrr )rBrr?<00>s
r?<00> pbkdf2:sha256<35>cCs2|dkrt|<02>nd}t|||<00>\}}d|||fS)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.
r6r-z%s$%s$%s)r5rG)rCrBZ salt_lengthr<00>hrEr r r<00>generate_password_hash<73>srRcCs:|<00>d<01>dkrdS|<00>dd<02>\}}}tt|||<01>d|<04>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.
<20>$r9Fr)<04>countr;r,rG)ZpwhashrCrBrZhashvalr r r<00>check_password_hash<73>s rUcsr|g}x`|D]X<><00>dkr"t<00><01><00><01>t<02>fdd<03>tD<00><01>sVtj<05><06><00>sV<73>dksV<73><00>d<05>rZdS|<02><08><00>q Wtj |<02>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``.
r-c3s|]}|<01>kVqdS)Nr )rr)<01>filenamer rr<00>szsafe_join.<locals>.<genexpr>z..z../N)
<EFBFBD> posixpath<74>normpath<74>any<6E> _os_alt_seps<70>os<6F>path<74>isabsr:<00>appendr3)<03> directoryZ pathnames<65>partsr )rVr<00> safe_join<69>s 

 
ra)rOrP)&<26>__doc__rr!rJr[rW<00>randomr<00>structr<00>_compatrrrrr r
r0r><00>packZ _pack_intr r%r.<00>listr\r<00>altseprZrrr,r5rGr?rRrUrar r r r<00><module>
s:        
  %