Encode and sign a pickle-able object. Return a (byte) string
(data, key, digestmod=None)
| 3058 | |
| 3059 | |
| 3060 | def cookie_encode(data, key, digestmod=None): |
| 3061 | """ Encode and sign a pickle-able object. Return a (byte) string """ |
| 3062 | depr(0, 13, "cookie_encode() will be removed soon.", |
| 3063 | "Do not use this API directly.") |
| 3064 | digestmod = digestmod or hashlib.sha256 |
| 3065 | msg = base64.b64encode(pickle.dumps(data, -1)) |
| 3066 | sig = base64.b64encode(hmac.new(tob(key), msg, digestmod=digestmod).digest()) |
| 3067 | return tob('!') + sig + tob('?') + msg |
| 3068 | |
| 3069 | |
| 3070 | def cookie_decode(data, key, digestmod=None): |