diff options
| author | David Poole <testcluster@gmail.com> | 2017-11-08 18:32:59 -0700 |
|---|---|---|
| committer | David Poole <testcluster@gmail.com> | 2017-11-08 18:32:59 -0700 |
| commit | 1dbaddd75e04365a822cf4bcf05f332a5f845ed6 (patch) | |
| tree | 0230eaf4b16b04152056440b7273d26b6c28571d /requests | |
| parent | 234f80af88ff2aab39bbd65a3131ae93e1917c25 (diff) | |
| download | python-requests-1dbaddd75e04365a822cf4bcf05f332a5f845ed6.tar.gz | |
for RFC-7616 add SHA-256 and SHA-512
Diffstat (limited to 'requests')
| -rw-r--r-- | requests/auth.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/requests/auth.py b/requests/auth.py index 1a182dff..4ae45947 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -153,6 +153,18 @@ class HTTPDigestAuth(AuthBase): x = x.encode('utf-8') return hashlib.sha1(x).hexdigest() hash_utf8 = sha_utf8 + elif _algorithm == 'SHA-256': + def sha256_utf8(x): + if isinstance(x, str): + x = x.encode('utf-8') + return hashlib.sha256(x).hexdigest() + hash_utf8 = sha256_utf8 + elif _algorithm == 'SHA-512': + def sha512_utf8(x): + if isinstance(x, str): + x = x.encode('utf-8') + return hashlib.sha512(x).hexdigest() + hash_utf8 = sha512_utf8 KD = lambda s, d: hash_utf8("%s:%s" % (s, d)) |
