title: How to use scrypt to generate hash for password and salt in Python
body: <p>I would like to use scrypt to create a hash for my users' passwords and salts.  I have found <a href="http://aleccolocco.blogspot.com/2011/09/how-to-protect-passwords-with-python.html" rel="noreferrer">two</a> <a href="http://kevinryan.me/using-scrypt-in-python-and-postgresql/" rel="noreferrer">references</a>, but there are things I don't understand about them.</p>
  
  <p>They use the scrypt encrypt and decrypt functions.  One encrypts a random string and the other encrypts the salt (which looks wrong since only the password and not the salt is used for decryption).  It looks like the decrypt function is being used to validate the password/salt as a side effect of the decryption.</p>
  
  <p>Based on the little I understand, what I want is a key derivation function (KDF) rather than encryption/decryption and that the KDF is likely generated and used by scrypt for encryption/decryption.  The actual KDF is used behind the scenes and I am concerned that blindly following these examples will lead to a mistake.  If the scrypt encrypt/decrypt functions are used to generate and verify the password, I don't understand the role of the string being encrypted.  Does its content or length matter?</p>