Encode and sign a pickle-able object. Return a (byte) string
(data, key)
| 2601 | |
| 2602 | |
| 2603 | def 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 | |
| 2610 | def cookie_decode(data, key): |