summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-26 13:37:34 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-27 10:50:50 +0200
commitd0e4dd5cdd743a5c43c4ccc2c8fa29d3982eaa71 (patch)
treeed64921a0f27e8df1b5ce69b729d34dfbfc9d815 /django/utils
parentc594574175e379fff356e274893d797f6e6a95fa (diff)
Fixed #36572 -- Revert "Fixed #36546 -- Deprecated django.utils.crypto.constant_time_compare() in favor of hmac.compare_digest()."
This reverts commit 0246f478882c26bc1fe293224653074cd46a90d0.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/crypto.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/django/utils/crypto.py b/django/utils/crypto.py
index b6145709c3..4b8146695a 100644
--- a/django/utils/crypto.py
+++ b/django/utils/crypto.py
@@ -5,10 +5,8 @@ Django's standard crypto functions and utilities.
import hashlib
import hmac
import secrets
-import warnings
from django.conf import settings
-from django.utils.deprecation import RemovedInDjango70Warning
from django.utils.encoding import force_bytes
@@ -66,12 +64,7 @@ def get_random_string(length, allowed_chars=RANDOM_STRING_CHARS):
def constant_time_compare(val1, val2):
"""Return True if the two strings are equal, False otherwise."""
- warnings.warn(
- "constant_time_compare() is deprecated. Use hmac.compare_digest() instead.",
- RemovedInDjango70Warning,
- stacklevel=2,
- )
- return hmac.compare_digest(val1, val2)
+ return secrets.compare_digest(force_bytes(val1), force_bytes(val2))
def pbkdf2(password, salt, iterations, dklen=0, digest=None):