code: def cookie_decode(data, key):
      ''' Verify and decode an encoded string. Return an object or None'''
      if isinstance(data, unicode): data = data.encode('ascii') #2to3 hack
      if cookie_is_encoded(data):
          sig, msg = data.split(u'?'.encode('ascii'),1) #2to3 hack
          if sig[1:] == base64.b64encode(hmac.new(key, msg).digest()):
             return pickle.loads(base64.b64decode(msg))
      return Nonf cookie_decode(data, key):
      ''' Verify and decode an encoded string. Return an object or None'''
      if isinstance(data, unicode): data = data.encode('ascii') #2to3 hack
      if cookie_is_encoded(data):
          sig, msg = data.split(u'?'.encode('ascii'),1) #2to3 hack
          if sig[1:] == base64.b64encode(hmac.new(key, msg).digest()):
             return pickle.loads(base64.b64decode(msg))
      return None
docs: Verify and decode an encoded string. Return an object or None