Обсуждение: SHA1 on postgres 8.3

Поиск
Список
Период
Сортировка

SHA1 on postgres 8.3

От
Jon Hancock
Дата:
I am trying to port a MySQL db to postgres 8.3rc1.
In MySQL I have a function SHA1, which is critical for storing and
authenticating passwords.
I see some old posts on how to add this function myself.  see:
http://raveica.comdurav.com/blog/programming/how-do-i-add-sha1-to-postgresql/

Has sha1 been added to the standard postgres 8.3?  or do I still need
to build my own version?
Are there updated instructions for this for 8.3?

thanks, Jon

Re: SHA1 on postgres 8.3

От
Martijn van Oosterhout
Дата:
On Sun, Jan 20, 2008 at 12:21:01AM -0800, Jon Hancock wrote:
> I am trying to port a MySQL db to postgres 8.3rc1.
> In MySQL I have a function SHA1, which is critical for storing and
> authenticating passwords.
> I see some old posts on how to add this function myself.  see:
> http://raveica.comdurav.com/blog/programming/how-do-i-add-sha1-to-postgresql/

It's in contrib in the pgcrypto module. If you use a distribution you
can usually simply just install it.

http://www.postgresql.org/docs/8.3/static/pgcrypto.html

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Вложения

Re: SHA1 on postgres 8.3

От
Julio Cesar Sánchez González
Дата:
Martijn van Oosterhout wrote:
> On Sun, Jan 20, 2008 at 12:21:01AM -0800, Jon Hancock wrote:
>
>> I am trying to port a MySQL db to postgres 8.3rc1.
>> In MySQL I have a function SHA1, which is critical for storing and
>> authenticating passwords.
>> I see some old posts on how to add this function myself.  see:
>> http://raveica.comdurav.com/blog/programming/how-do-i-add-sha1-to-postgresql/
>>
>
> It's in contrib in the pgcrypto module. If you use a distribution you
> can usually simply just install it.
>
> http://www.postgresql.org/docs/8.3/static/pgcrypto.html
>
> Have a nice day,
>

After you installed pgcrypto.so, just create a small function:

CREATE OR REPLACE FUNCTION sha1(text) RETURNS text AS '
SELECT
ENCODE(DIGEST($1, ''sha1"),"hex") AS result
' LANGUAGE 'SQL';


--
Regards,

Julio Cesar Sánchez González.

--
Ahora me he convertido en la muerte, destructora de mundos.
Soy la Muerte que se lleva todo, la fuente de las cosas que vendran.

www.sistemasyconectividad.com.mx        http://darkavngr.blogspot.com/