postgresql/contrib/pgcrypto
Bruce Momjian cb5427ee47 I would like to do a interface change in pgcrypto. (Good
timing, I know :))  At the moment the digest() function returns
hexadecimal coded hash, but I want it to return pure binary.  I
have also included functions encode() and decode() which support
'base64' and 'hex' encodings, so if anyone needs digest() in hex
he can do encode(digest(...), 'hex').

Main reason for it is "to do one thing and do it well" :)

Another reason is if someone needs really lot of digesting, in
the end he wants to store the binary not the hexadecimal result.
It is really silly to convert it to hex then back to binary
again.  As I said if someone needs hex he can get it.

Well, and the real reason that I am doing encrypt()/decrypt()
functions and _they_ return binary.  For testing I like to see
it in hex occasionally, but it is really wrong to let them
return hex.  Only now it caught my eye that hex-coding in
digest() is wrong.  When doing digest() I thought about 'common
case' but hacking with psql is probably _not_ the common case :)

Marko Kreen
2001-01-24 03:46:16 +00:00
..
Makefile I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
README.pgcrypto I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
encode.c I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
encode.h I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
internal.c Hashing functions from Marko Kreen <marko@l-t.ee> 2000-10-31 13:11:28 +00:00
krb.c Hashing functions from Marko Kreen <marko@l-t.ee> 2000-10-31 13:11:28 +00:00
md5.c The KAME files md5.* and sha1.* have the following changelog 2001-01-09 16:07:14 +00:00
md5.h The KAME files md5.* and sha1.* have the following changelog 2001-01-09 16:07:14 +00:00
mhash.c Hashing functions from Marko Kreen <marko@l-t.ee> 2000-10-31 13:11:28 +00:00
openssl.c Hashing functions from Marko Kreen <marko@l-t.ee> 2000-10-31 13:11:28 +00:00
pgcrypto.c I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
pgcrypto.h The KAME files md5.* and sha1.* have the following changelog 2001-01-09 16:07:14 +00:00
pgcrypto.sql.in I would like to do a interface change in pgcrypto. (Good 2001-01-24 03:46:16 +00:00
sha1.c The KAME files md5.* and sha1.* have the following changelog 2001-01-09 16:07:14 +00:00
sha1.h The KAME files md5.* and sha1.* have the following changelog 2001-01-09 16:07:14 +00:00

README.pgcrypto

DESCRIPTION

  Here are various cryptographic and otherwise useful
  functions for PostgreSQL.

    encode(data, type)
        encodes binary data into ASCII-only representation.
	Types supported are 'hex' and 'base64'.

    decode(data, type)
    	decodes the data processed by encode()

    digest(data::text, hash_name::text)
	which returns cryptographic checksum over data by
	specified algorithm. eg

	> select encode(digest('blah', 'sha1'), 'hex');
	5bf1fd927dfb8679496a2e6cf00cbe50c1c87145

    digest_exists(hash_name::text)::bool
	which reports if particular hash type exists.

  If any of arguments are NULL they return NULL.

HASHES

  For choosing library you must edit Makefile.

  standalone (default):
	MD5, SHA1

	(the code is from KAME project.  Actually I hate code
	duplication, but I also want to quarantee that MD5 and
	SHA1 exist)

  mhash (0.8.1):
	MD5, SHA1, CRC32, CRC32B, GOST, TIGER, RIPEMD160,
	HAVAL(256,224,192,160,128)

  openssl:
	MD5, SHA1, RIPEMD160, MD2

  kerberos5 (heimdal):
	MD5, SHA1