pgcrypto : how to get SHA1(string) as a 40-char string, NOT binary string?

From: Miles Keaton <mileskeaton(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pgcrypto : how to get SHA1(string) as a 40-char string, NOT binary string?
Date: 2005-07-13 07:45:19
Message-ID: 59b2d39b05071300457030a7ad@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have the contrib/pgcrypto installed.
I want to get the 40-character hash from SHA1

Example: SELECT digest('blue', 'sha1') would be:
4c9a82ce72ca2519f38d0af0abbb4cecb9fceca9

I was surprised and disappointed to get a binary-hash back.

Does anyone know how to get the regular 40-character string back from
SHA1 instead of the binary-hash? (Or how to convert a binary-hash
into a-z0-9 chars?)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bjørn T Johansen 2005-07-13 07:59:12 Re: Windows version of PostgreSQL 8?
Previous Message Josef Springer 2005-07-13 07:34:52 CreateTable --> schema not found