Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encrypt/decrypt columns in a Grails domain class?

As i want to introduce some data security i was wondering if it is possible to encrypt/decrypt specific columns in a Grails domain class and if so what the easiest way is to achieve such a thing?

Let say i have a User class and want to encrypt ssn number or bankaccount number so these are not stored as plain text in the DB.. what would be the best approach?

like image 821
Marco Avatar asked Oct 28 '25 09:10

Marco


2 Answers

I created the jasypt encryption plugin for doing exactly this. Docs are on the linked bitbucket wiki and there's also slides from a presentation that I've given on it's use.

It makes it easy to just annotate your domain classes to do field level encryption on the fields you want to protect (by default with the Bouncy Castle AES encryption provider).

like image 75
Ted Naleid Avatar answered Oct 31 '25 08:10

Ted Naleid


Hibernate user types can transform to and from another format for storage to transparently encrypt the column.

Here's a simple implementation for grails: http://www.redtoad.ca/ataylor/2011/12/encrypting-a-database-column-in-grails/.

like image 41
ataylor Avatar answered Oct 31 '25 08:10

ataylor