Blowfish Encrypted String

Started by Craig Boydover 12 years ago4 messagesgeneral
Jump to latest
#1Craig Boyd
craigboyd0@gmail.com

Hello All,

I have a string in a program that I have encrypted using Blowfish and I am
now trying to figure out the best way to store that in PostgreSQL so that I
can store it and retrieve it later for decryption. I have searched around
and have not found some good examples of how to go about this.

So my first questions is: Can someone point me to a tutorial or posting
that shows how one might do that?

Failing that:
What data type should I use to store this?
What does the SQL look like to INSERT/SELECT the field?

Thanks,

Craig

#2Dmitriy Igrishin
dmitigr@gmail.com
In reply to: Craig Boyd (#1)
Re: Blowfish Encrypted String

2013/9/26 Craig Boyd <craigboyd0@gmail.com>

Hello All,

I have a string in a program that I have encrypted using Blowfish and I am
now trying to figure out the best way to store that in PostgreSQL so that I
can store it and retrieve it later for decryption. I have searched around
and have not found some good examples of how to go about this.

So my first questions is: Can someone point me to a tutorial or posting
that shows how one might do that?

Failing that:
What data type should I use to store this?

I believe that you should use bytea datatype.

What does the SQL look like to INSERT/SELECT the field?

Just like any other INSERT/SELECT query.

--
// Dmitriy.

#3Craig Boyd
craigboyd0@gmail.com
In reply to: Dmitriy Igrishin (#2)
Re: Blowfish Encrypted String

Dmitriy,

Thank you very much for the reply!

Right...got the the data type...but how do I actually insert a binary
string into the column? What does the SQL look like?
For the moment assume I have the following bit of binary: 4PO„âÔ™ä²

What does the SQL look like to insert that into the bytea column?
(FYI...most of my binary data would be only slightly bigger than what I
just pasted here. I am not storing Word documents or images, just some
encrypted strings of test that are not more than 100 characters long and
typically about 16 to 20.

Thanks,

Craig Boyd

On Thu, Sep 26, 2013 at 11:46 AM, Dmitriy Igrishin <dmitigr@gmail.com>wrote:

Show quoted text

2013/9/26 Craig Boyd <craigboyd0@gmail.com>

Hello All,

I have a string in a program that I have encrypted using Blowfish and I
am now trying to figure out the best way to store that in PostgreSQL so
that I can store it and retrieve it later for decryption. I have searched
around and have not found some good examples of how to go about this.

So my first questions is: Can someone point me to a tutorial or posting
that shows how one might do that?

Failing that:
What data type should I use to store this?

I believe that you should use bytea datatype.

What does the SQL look like to INSERT/SELECT the field?

Just like any other INSERT/SELECT query.

--
// Dmitriy.

#4Steven Schlansker
steven@likeness.com
In reply to: Craig Boyd (#3)
Re: Blowfish Encrypted String

On Sep 26, 2013, at 10:55 AM, Craig Boyd <craigboyd0@gmail.com> wrote:

Dmitriy,

Thank you very much for the reply!

Right...got the the data type...but how do I actually insert a binary string into the column? What does the SQL look like?
For the moment assume I have the following bit of binary: 4PO„âÔ™ä²

What does the SQL look like to insert that into the bytea column? (FYI...most of my binary data would be only slightly bigger than what I just pasted here. I am not storing Word documents or images, just some encrypted strings of test that are not more than 100 characters long and typically about 16 to 20.

http://www.postgresql.org/docs/devel/static/datatype-binary.html

Most client libraries will have functionality to do this nicely (e.g. sending a Java byte[] to a Postgres bytea); it sucks somewhat to do it by hand in SQL.

Thanks,

Craig Boyd

On Thu, Sep 26, 2013 at 11:46 AM, Dmitriy Igrishin <dmitigr@gmail.com> wrote:

2013/9/26 Craig Boyd <craigboyd0@gmail.com>
Hello All,

I have a string in a program that I have encrypted using Blowfish and I am now trying to figure out the best way to store that in PostgreSQL so that I can store it and retrieve it later for decryption. I have searched around and have not found some good examples of how to go about this.

So my first questions is: Can someone point me to a tutorial or posting that shows how one might do that?

Failing that:
What data type should I use to store this?
I believe that you should use bytea datatype.
What does the SQL look like to INSERT/SELECT the field?
Just like any other INSERT/SELECT query.

--
// Dmitriy.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general