MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / cookie_decode

Function cookie_decode

21-async/mojifinder/bottle.py:2610–2617  ·  view source on GitHub ↗

Verify and decode an encoded string. Return an object or None.

(data, key)

Source from the content-addressed store, hash-verified

2608
2609
2610def cookie_decode(data, key):
2611 ''' Verify and decode an encoded string. Return an object or None.'''
2612 data = tob(data)
2613 if cookie_is_encoded(data):
2614 sig, msg = data.split(tob('?'), 1)
2615 if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg, digestmod=hashlib.md5).digest())):
2616 return pickle.loads(base64.b64decode(msg))
2617 return None
2618
2619
2620def cookie_is_encoded(data):

Callers 1

get_cookieMethod · 0.85

Calls 3

tobFunction · 0.85
cookie_is_encodedFunction · 0.85
_lscmpFunction · 0.85

Tested by

no test coverage detected