Re: Encrypted column - Mailing list pgsql-general

From Marko Kreen
Subject Re: Encrypted column
Date
Msg-id e51f66da0706050712u3c59a369n986ae56344912a24@mail.gmail.com
Whole thread Raw
In response to Re: Encrypted column  (Tino Wildenhain <tino@wildenhain.de>)
Responses Re: Encrypted column  ("Brian Mathis" <brian.mathis@gmail.com>)
Re: Encrypted column  (Tino Wildenhain <tino@wildenhain.de>)
List pgsql-general
On 6/5/07, Tino Wildenhain <tino@wildenhain.de> wrote:
> Ranieri Mazili schrieb:
> > Hello,
> >
> > I need to store users and passwords on a table and I want to store it
> > encrypted, but I don't found documentation about it, how can I create a
> > table with columns "user" and "password" with column "password"
> > encrypted and how can I check if "user" and "password" are correct using
> > a sql query ?
>
> Passwords are usually not encrypted but hashed instead. A common hash
> function is available in postgres w/o any additional extension:
>
> md5()
>
> The rule is, if two hashes compare equal, then the original data must
> be equal (yes, there are chances for collisions, but practically very
> low. See also sha1 and friends in the pgcrypto contrib module)

Both md5 and sha1 are bad for passwords, no salt and easy to
bruteforce - due to the tiny amount of data in passwords.

Proper ways is to use crypt() function from pgcrypto module.
Due to historical accident is has bad name which hints at
encryption, actually its only purpose is to hash passwords.
Read more in pgcrypto doc.

--
marko

pgsql-general by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: CREATE RULE with WHERE clause
Next
From: "Brian Mathis"
Date:
Subject: Re: Encrypted column