Sunday, 15 April 2012

How should I encrypt API tokens in Python? -


I've written a basic Python application that uses Twitter's API. I need to be able to encrypt my API secret because it is never human-readable within my program (word of Twitter). How should I do this in Python? Is this possible?

Store an API key in an external file and load it over runtime. Just make sure the external file never do or publish it once it enters the key of the load to prevent them from actually stealing (especially if they have a source to open your dispute).

This is a raw example, I'm sure you can refine it to your needs:

Secret_keys file:

  {" TWITTER_SECRET ":" somebase64encodedkey "}  

dragon:

  import json secrets_filename = 'secret_keys' api_keys = {} # Somebase64encodedkey  

No comments:

Post a Comment