def cookie_decode(data, key):
data = tob(data)<EOL>if cookie_is_encoded(data):<EOL><INDENT>sig, msg = data.split(tob('<STR_LIT:?>'), <NUM_LIT:1>)<EOL>if _lscmp(sig[<NUM_LIT:1>:], base64.b64encode(hmac.new(tob(key), msg).digest())):<EOL><INDENT>return pickle.loads(base64.b64decode(msg))<EOL><DEDENT><DEDENT>return None<EOL>
Verify and decode an encoded string. Return an object or None.