crypto in Rails 2.x?

Jeff Pritchard wrote:

I need to encrypt some items in the database in a rails app.

I tried using the old "sentry" gem, but it doesn't seem to be surviving Rails 2. The stuff I found for Active Crypto on the web appeared to be many years old.

What are folks using to encrypt db data via active record these days?

thanks, jp

I'm starting to question the validity of this whole notion. It seems to be expected that one would encrypt database tables that hold sensitive information (like a user's health information for example).

Taking a step back from it though, what's the point? The database and my app are all on the same server. Nobody can see the database files unless they have access to my server. Anybody who does have access to my server can look at the app to figure out how to read the encrypted database tables/columns.

So what is the supposed advantage of encrypting them in the first place???

Sorry for playing my own devil's advocate here, but it just dawned on me that perhaps I was chasing a fool's errand. Please enlighten me.

thanks, jp

It may depend on the likelihood of someone leaving a CD backup copy of the database on a train (or a laptop with a copy of the db), and of how embarrassing that would be.

If you are handling private personal information or commercially confidential data you must consider the possibility of litigation if the data escapes.


Running the application usually involves some sort of user rights. If the passwords aren’t stored on the server, then running the app won’t give access to the data. Just don’t leave the keys in plain text on the server and don’t leave user account info on the server.

One consideration: Encrypting in the app layer may become very painful if you want to do sql maintenance of your database.

Regards, Nick