Thread: How to use pgcrypto?

How to use pgcrypto?

From
"Dylan Milks"
Date:
Hi. I've read some of the documentation on how to use use pgcrypto, but I still can't seem to get it working properly.

All I want to do is encrypt a field (using the AES algorithm) before inserting into the table, and consequently decrypt
thatsame field when I pull it out. 

Example (my table is called "encode_test" and it has one field "username"):

INSERT INTO encode_test(username) values(encrypt('testpassword','key','aes-cbc/pad:none'));

SELECT decrypt(username,'key','aes-cbc/pad:none') FROM encode_test;

But when I insert and select it out, all I see are question marks (?). What am I doing wrong? Can anyone give me a
concreteexample to follow. All the examples in the documentation are not very clear. 

Thanks,
Dylan

Attachment