def signed_serialize(data, secret):
 pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
 try:
  secret = bytes_(secret)
 except UnicodeEncodeError:
  secret = bytes_(secret, 'utf-8')
 sig = hmac.new(secret, pickled, hashlib.sha1).hexdigest()
 return (sig + native_(base64.b64encode(pickled)))

def signed_serialize ( data , secret ) : pickled = pickle . dumps ( data , pickle . HIGHEST_PROTOCOL ) try : secret = bytes_ ( secret ) except UnicodeEncodeError : secret = bytes_ ( secret , 'utf-8' ) sig = hmac . new ( secret , pickled , hashlib . sha1 ) . hexdigest ( ) return ( sig + native_ ( base64 . b64encode ( pickled ) ) )
serialize any pickleable structure and sign it using the secret .