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?
-
Answer:
I created the http://grails.org/plugin/jasypt-encryption for doing exactly this. Docs are on the linked bitbucket wiki and there's also http://www.slideshare.net/tednaleid/grails-jasypt-encryption-plugin 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).
Marco at Stack Overflow Visit the source
Other answers
Override the get/set methods for the domain property to encrypt going in and decrypt coming out. You'll just need to choose the right crypto algorithm. Obviously, make sure you choose one that is 2-way.
Gregg
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/.
ataylor
Related Q & A:
- how to encrypt with openssl?Best solution by Unix and Linux
- How to make collapsible columns for a table?Best solution by Stack Overflow
- How to encrypt JavaScript code?Best solution by Stack Overflow
- What is a typical college class like? How different is it from High School?Best solution by campusexplorer.com
- How can I get a free domain?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.