title: Salt and hash a password in Python
body: <p>This code is supposed to hash a password with a salt.  The salt and hashed password are being saved in the database.  The password itself is not.</p>
  
  <p>Given the sensitive nature of the operation, I wanted to make sure everything was kosher.  </p>
  
  <pre><code>import hashlib
  import base64
  import uuid
  
  password = 'test_password'
  salt     = base64.urlsafe_b64encode(uuid.uuid4().bytes)
  
  
  t_sha = hashlib.sha512()
  t_sha.update(password+salt)
  hashed_password =  base64.urlsafe_b64encode(t_sha.digest())
  </code></pre>