Results 1 to 3 of 3

Thread: Encryption

  1. #1
    Join Date
    Mar 2003
    Posts
    3

    Unanswered: Encryption

    Can somebody tell me, if there's a function to encrypt data in PostgreSQL?
    Thanks in advance.
    Lizeth

  2. #2
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    As far as I know there are no built in encrypt/decrypt functions for postgresql.

  3. #3
    Join Date
    Apr 2003
    Location
    Bucharest, RO
    Posts
    2

    Re: Encryption

    Originally posted by lflores
    Can somebody tell me, if there's a function to encrypt data in PostgreSQL?
    Thanks in advance.
    Lizeth
    Yes, there is. It all depends on how you're using postgresql; if compiled from source, and source is in /usr/local/src/postgresql-7.x.y then go there and :
    cd contrib
    cd pgcrypto
    # see readme & edit the makefile
    make; make install

    Then I connected to template1 as postgres and ran the pgcrypto.sql script to create the functions.
    Thus all your newly created databases will have those funcs available.
    A simple BlowFish test looks like:
    SELECT encode(encrypt('bla bla bla', 'fooz', 'bf'), 'hex');
    SELECT decrypt(decode('b6d35800734e419d68724c9c8b7e584f', 'hex'), 'fooz', 'bf');
    where
    - encode(bytea, text) hex-encodes a byte array
    - encrypt(data, key, algo) encrypts
    - decrypt(data, key, algo) decrypts
    I use encode to get "normal" results.

    HIH,
    Feel free to ask more questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •