PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea Value in stored procedure

From: "Enrico Riedel" <enricoriedel(at)thunderelectricinc(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea Value in stored procedure
Date: 2005-07-08 21:43:41
Message-ID: 20050708214342.08E1E529C8@svr1.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I have the following scenario:
Table:
Fil_no BigSerial
Fil_Name varchar
Fil_Data Bytea
Fil_HASH varchar

Trigger:
Before Insert (in Pseudo Code)
...
vchSHA = SHA(Fil_DATA)
NEW.Fil_HASH = vchSHA
...

I tried to find a function that calculates the SHA (preference is sha-256),
but could not find anything for PostGRE. However, I want to implement the
calculation within the DB, for several reasons.

Has anyone an idea on how or any pointer into the right direction to
accomplish the above task?

Thanks already in advance!

-Enrico

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2005-07-08 22:30:34 Re: Postgresql performance on Opteron 8 CPU
Previous Message Adam Pritchard 2005-07-08 20:27:12 many updates to single row in single transaction