mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
> Postgres 7.1.0), and I think I've found a bug. > > I compiled Pgcrypto with OpenSSL, using gcc 2.95.4 and > OpenSSL 0.9.6a (the latest Debian 'unstable' packages). > web=> select encode(digest('blah', 'sha1'), 'base64'); > FATAL 1: pg_encode: overflow, encode estimate too small > pqReadData() -- backend closed the channel unexpectedly. > This probably means the backend terminated abnormally > before or while processing the request. > The connection to the server was lost. Attempting reset: Succeeded. > Is this a bug? Can it be fixed? This is a bug alright. And a silly one :) Marko Kreen
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 ENCRYPTION There is experimental version out with encryption, HMAC and UN*X crypt() support in http://www.l-t.ee/marko/pgsql/ Current latest release is pgcrypto-0.3.tar.gz.