diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index 248791d..1ac1afe 100644
a
|
b
|
|
1 | 1 | import hmac |
2 | 2 | |
3 | 3 | from django.conf import settings |
4 | | from django.utils.hashcompat import sha_constructor |
| 4 | from django.utils.hashcompat import sha_hmac |
5 | 5 | from django.contrib.messages import constants |
6 | 6 | from django.contrib.messages.storage.base import BaseStorage, Message |
7 | 7 | from django.utils import simplejson as json |
… |
… |
class MessageDecoder(json.JSONDecoder):
|
41 | 41 | decoded = super(MessageDecoder, self).decode(s, **kwargs) |
42 | 42 | return self.process_messages(decoded) |
43 | 43 | |
44 | | |
45 | 44 | class CookieStorage(BaseStorage): |
46 | 45 | """ |
47 | 46 | Stores messages in a cookie. |
… |
… |
class CookieStorage(BaseStorage):
|
103 | 102 | SECRET_KEY, modified to make it unique for the present purpose. |
104 | 103 | """ |
105 | 104 | key = 'django.contrib.messages' + settings.SECRET_KEY |
106 | | return hmac.new(key, value, sha_constructor).hexdigest() |
| 105 | return hmac.new(key, value, sha_hmac).hexdigest() |
107 | 106 | |
108 | 107 | def _encode(self, messages, encode_empty=False): |
109 | 108 | """ |
diff --git a/django/utils/hashcompat.py b/django/utils/hashcompat.py
index 8880d92..b1e6021 100644
a
|
b
|
available.
|
8 | 8 | try: |
9 | 9 | import hashlib |
10 | 10 | md5_constructor = hashlib.md5 |
| 11 | md5_hmac = md5_constructor |
11 | 12 | sha_constructor = hashlib.sha1 |
| 13 | sha_hmac = sha_constructor |
12 | 14 | except ImportError: |
13 | 15 | import md5 |
14 | 16 | md5_constructor = md5.new |
| 17 | md5_hmac = md5 |
15 | 18 | import sha |
16 | 19 | sha_constructor = sha.new |
| 20 | sha_hmac = sha |