@assert_crypto_availability
def decrypt_data(token, secret, data):
 if data.startswith(ENCRYPT_MARKER):
  try:
   encoded_data = data[len(ENCRYPT_MARKER):]
   aes_key = generate_aes_key(token, secret)
   decoded_data = base64.b64decode(encoded_data)
   iv = decoded_data[:16]
   encrypted_data = decoded_data[16:]
   cipher = AES.new(aes_key, AES.MODE_CFB, iv)
   decrypted_data = cipher.decrypt(encrypted_data)
   return json.loads(decrypted_data)
  except:
   raise DecryptError('data appeared to be corrupted')
 else:
  return data

@ assert_crypto_availability def decrypt_data ( token , secret , data ) : if data . startswith ( ENCRYPT_MARKER ) : try : encoded_data = data [ len ( ENCRYPT_MARKER ) : ] aes_key = generate_aes_key ( token , secret ) decoded_data = base64 . b64decode ( encoded_data ) iv = decoded_data [ : 16 ] encrypted_data = decoded_data [ 16 : ] cipher = AES . new ( aes_key , AES . MODE_CFB , iv ) decrypted_data = cipher . decrypt ( encrypted_data ) return json . loads ( decrypted_data ) except : raise DecryptError ( 'data appeared to be corrupted' ) else : return data
decrypt the data with the given secret key .