From 53a8c797aaae64fbc851d22b986eb83a625fb71c Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Mon, 30 Mar 2026 09:38:52 -0600 Subject: [PATCH] Move DigestAuth hash algorithms to use usedforsecurity=False --- src/requests/auth.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/requests/auth.py b/src/requests/auth.py index c39b645189..36082b5ed1 100644 --- a/src/requests/auth.py +++ b/src/requests/auth.py @@ -145,7 +145,7 @@ def build_digest_header(self, method, url): def md5_utf8(x): if isinstance(x, str): x = x.encode("utf-8") - return hashlib.md5(x).hexdigest() + return hashlib.md5(x, usedforsecurity=False).hexdigest() hash_utf8 = md5_utf8 elif _algorithm == "SHA": @@ -153,7 +153,7 @@ def md5_utf8(x): def sha_utf8(x): if isinstance(x, str): x = x.encode("utf-8") - return hashlib.sha1(x).hexdigest() + return hashlib.sha1(x, usedforsecurity=False).hexdigest() hash_utf8 = sha_utf8 elif _algorithm == "SHA-256": @@ -161,7 +161,7 @@ def sha_utf8(x): def sha256_utf8(x): if isinstance(x, str): x = x.encode("utf-8") - return hashlib.sha256(x).hexdigest() + return hashlib.sha256(x, usedforsecurity=False).hexdigest() hash_utf8 = sha256_utf8 elif _algorithm == "SHA-512": @@ -169,7 +169,7 @@ def sha256_utf8(x): def sha512_utf8(x): if isinstance(x, str): x = x.encode("utf-8") - return hashlib.sha512(x).hexdigest() + return hashlib.sha512(x, usedforsecurity=False).hexdigest() hash_utf8 = sha512_utf8 @@ -202,7 +202,7 @@ def sha512_utf8(x): s += time.ctime().encode("utf-8") s += os.urandom(8) - cnonce = hashlib.sha1(s).hexdigest()[:16] + cnonce = hashlib.sha1(s, usedforsecurity=False).hexdigest()[:16] if _algorithm == "MD5-SESS": HA1 = hash_utf8(f"{HA1}:{nonce}:{cnonce}")