Re: PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea

From: Stuart Bishop <stuart(at)stuartbishop(dot)net>
To: Enrico Riedel <enricoriedel(at)thunderelectricinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea
Date: 2005-07-13 02:18:35
Message-ID: 42D479FB.80509@stuartbishop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Enrico Riedel wrote:

> Has anyone an idea on how or any pointer into the right direction to
> accomplish the above task?
>
> Thanks already in advance!

If you don't mind having plpythonu installed in your database, a lot of this
sort of thing becomes trivial:

CREATE OR REPLACE FUNCTION sha1(text) RETURNS char(40) AS '
import sha
return sha.new(args[0]).hexdigest()
' LANGUAGE plpythonu IMMUTABLE RETURNS NULL ON NULL INPUT;

--
Stuart Bishop <stuart(at)stuartbishop(dot)net>
http://www.stuartbishop.net/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Terenzio 2005-07-13 03:30:23 current_timestamp - 20 minutes
Previous Message Michael Fuhr 2005-07-13 02:08:47 Re: dynamically loaded functions