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

Function cookie_encode

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

Encode and sign a pickle-able object. Return a (byte) string

(data, key)

Source from the content-addressed store, hash-verified

2601
2602
2603def cookie_encode(data, key):
2604 ''' Encode and sign a pickle-able object. Return a (byte) string '''
2605 msg = base64.b64encode(pickle.dumps(data, -1))
2606 sig = base64.b64encode(hmac.new(tob(key), msg, digestmod=hashlib.md5).digest())
2607 return tob('!') + sig + tob('?') + msg
2608
2609
2610def cookie_decode(data, key):

Callers 1

set_cookieMethod · 0.85

Calls 1

tobFunction · 0.85

Tested by

no test coverage detected