Re: Inserting encrypted data into postgres

From: "James F(dot) Hranicky" <jfh(at)cise(dot)ufl(dot)edu>
To: "K Old" <kevsurf4(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inserting encrypted data into postgres
Date: 2001-10-04 00:45:33
Message-ID: 20011004004533.48FA7D809@mail.cise.ufl.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"K Old" <kevsurf4(at)hotmail(dot)com> wrote:
> Hello,
>
> I am trying to load encrypted data (a credit card number encrypted by the
> Crypt::Twofish perl library) and postgres won't accept the data. I have
> tried escaping each character, and nothing works.
>
>
> For example a credit card number like
>
> 7384998737264839
>
> when encrypted by Crypt::Twofish would look like
>
> q.'
>
> I cannot get postgres to accept this input. Any ideas of different
> datatypes, or ways I can get it to accept this highly encrypted string?
>
> I have several modules that encrypt the string with letters and numbers
> rather than symbols, etc. like Twofish, but would love to have this solution
> work.

How about using the MIME::Base64 module?

From MIME::Base64(3) :

use MIME::Base64;

$encoded = encode_base64('Aladdin:open sesame');
$decoded = decode_base64($encoded);

You could do something like this pseudo-code:

insert into db values ("userid", encode_base64($crypted));

($userid, $enc_cardno) = select * from db where userid = "Bob";
$cardno = decrypt(decode_base64($enc_cardno));

----------------------------------------------------------------------
| Jim Hranicky, Senior SysAdmin UF/CISE Department |
| E314D CSE Building Phone (352) 392-1499 |
| jfh(at)cise(dot)ufl(dot)edu http://www.cise.ufl.edu/~jfh |
----------------------------------------------------------------------

Browse pgsql-general by date

  From Date Subject
Next Message Michael R. Fahey 2001-10-04 03:05:11 Re: Can't add PL/PGSQL function even after running createlang.
Previous Message Chris Bitmead 2001-10-04 00:37:29 What character can be stored in TEXT?