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

陌路散爱 提交于 2019-12-04 14:29:45

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).

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/.

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.

class Login{
        String userId
        String password

static mapping = {
        userId type: GormEncryptedStringType
        password type: GormEncryptedStringType
    }
}

read more here:- http://www.slideshare.net/tednaleid/grails-jasypt-encryption-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!