Re: PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea - Mailing list pgsql-general

From Stuart Bishop
Subject Re: PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea
Date
Msg-id 42D479FB.80509@stuartbishop.net
Whole thread Raw
In response to PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea Value in stored procedure  ("Enrico Riedel" <enricoriedel@thunderelectricinc.com>)
List 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@stuartbishop.net>
http://www.stuartbishop.net/

Attachment

pgsql-general by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Japanese words not distinguished
Next
From: Matthew Terenzio
Date:
Subject: current_timestamp - 20 minutes