Skip to content

Commit

Permalink
fix #1181: digestmod parameter is now required since Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Dec 1, 2019
1 parent 099c4a2 commit bdbab79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ def _lscmp(a, b):
def cookie_encode(data, key):
''' Encode and sign a pickle-able object. Return a (byte) string '''
msg = base64.b64encode(pickle.dumps(data, -1))
sig = base64.b64encode(hmac.new(tob(key), msg).digest())
sig = base64.b64encode(hmac.new(tob(key), msg, digestmod="md5").digest())
return tob('!') + sig + tob('?') + msg


Expand All @@ -2606,7 +2606,7 @@ def cookie_decode(data, key):
data = tob(data)
if cookie_is_encoded(data):
sig, msg = data.split(tob('?'), 1)
if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg).digest())):
if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg, digestmod="md5").digest())):
return pickle.loads(base64.b64decode(msg))
return None

Expand Down

0 comments on commit bdbab79

Please sign in to comment.