What is the recommended way to encrypt user passwords in a database?

perl, postgresql, security

Solution

Use SHA1 or SHA256 hashing with salting. Thats the way to go for storing passwords.

Problem

In a web application written in Perl and using PostgreSQL the users have username and password. What would be the recommended way to store the passwords? Encrypting them using the `crypt()` function of Perl and a random salt? That would limit the useful length of passswords to 8 characters and will require fetching the stored password in order to compare to the one given by the user when authenticating (to fetch the salt that was attached to it). Is there a built-in way in PostgreSQL to do this? Should I use Digest::MD5?

Original source