title: Safely storing encrypted credentials in django
body: <p>I'm working on a python/django app which, among other things, syncs data to a variety of other services, including samba shares, ssh(scp) servers, Google apps, and others. As such, it needs to store the credentials to access these services. Storing them as unencrypted fields would be, I presume, a Bad Idea, as an SQL injection attack could retrieve the credentials. So I would need to encrypt the creds before storage - are there any reliable libraries to achieve this?</p>
  
  <p>Once the creds are encrypted, they would need to be decrypted before being usable. There are two use cases for my app:</p>
  
  <ul>
  <li>One is interactive - in this case the user would provide the password to unlock the credentials. </li>
  <li>The other is an automated sync - this is started by a cron job or similar. Where would I keep the password in order to minimise risk of exploits here?</li>
  </ul>
  
  <p>Or is there a different approach to this problem I should be taking?</p>