pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guy Fraser <guy@incentre.net>
To: pgsql-sql@postgresql.org
Subject: Re: pgcrypto-crypt
Date: Thu, 06 Apr 2006 12:23:27 -0600
Message-ID: <1144347808.15065.18.camel@sigurd.incentre.net> (raw)
In-Reply-To: <ad39daf90604060123s7972677cx95c852a59caf94fd@mail.gmail.com>
References: <ad39daf90604060123s7972677cx95c852a59caf94fd@mail.gmail.com>

On Thu, 2006-06-04 at 13:53 +0530, AKHILESH GUPTA wrote:
> dear all,
> i want to encrypt and decrypt one of the fields in my table (i.e-
> password field)
> i have searched and with the help of pgcrypto package, using function
> "crypt", i am able to encrypt my data,
> but there is nothing which i found to decrypt that same data,
> plz anybody give me the function to decrypt that encrypted value.....
> plz reply asap

I found this with Google, maybe it will help you.

CREATE TABLE crypto (
id SERIAL PRIMARY KEY,
title VARCHAR(50),
crypted_content BYTEA
);


INSERT INTO crypto VALUES (1,'test1',encrypt('daniel', 'fooz', 'aes'));
INSERT INTO crypto VALUES (2,'test2',encrypt('struck', 'fooz', 'aes'));
INSERT INTO crypto VALUES (3,'test3',encrypt('konz', 'fooz', 'aes'));

SELECT * FROM crypto;

SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto;

SELECT *,decrypt(crypted_content, 'fooz', 'aes') FROM crypto WHERE
decrypt(crypted_content, 'fooz', 'aes') = 'struck';

I could not test it, since I do not have pgcrypto installed.





view thread (5+ messages)  latest in thread

Message-ID: <1144347808.15065.18.camel@sigurd.incentre.net>
Permalink:  ../1144347808.15065.18.camel@sigurd.incentre.net/
Also on:    postgresql.org/message-id/1144347808.15065.18.camel@sigurd.incentre.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: guy@incentre.net
  Subject: Re: pgcrypto-crypt
  In-Reply-To: <1144347808.15065.18.camel@sigurd.incentre.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox