MCPcopy Create free account
hub / github.com/datapane/datapane / cookie_decode

Function cookie_decode

python-client/src/datapane/_vendor/bottle.py:3070–3081  ·  view source on GitHub ↗

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

(data, key, digestmod=None)

Source from the content-addressed store, hash-verified

3068
3069
3070def cookie_decode(data, key, digestmod=None):
3071 """ Verify and decode an encoded string. Return an object or None."""
3072 depr(0, 13, "cookie_decode() will be removed soon.",
3073 "Do not use this API directly.")
3074 data = tob(data)
3075 if cookie_is_encoded(data):
3076 sig, msg = data.split(tob('?'), 1)
3077 digestmod = digestmod or hashlib.sha256
3078 hashed = hmac.new(tob(key), msg, digestmod=digestmod).digest()
3079 if _lscmp(sig[1:], base64.b64encode(hashed)):
3080 return pickle.loads(base64.b64decode(msg))
3081 return None
3082
3083
3084def cookie_is_encoded(data):

Callers

nothing calls this directly

Calls 4

deprFunction · 0.85
tobFunction · 0.85
cookie_is_encodedFunction · 0.85
_lscmpFunction · 0.85

Tested by

no test coverage detected