简体   繁体   中英

How do I encrypt a string in a Grails domain class?

For example, I created this domain class:

package loginproject

class User {

    String name
    String password
    Boolean state

    static constraints = {
    }
}

I think it is a good idea to encrypt the password string but I do not know where to start. What algorithm? What do I need to do?

You can utilize a plugin, such as Spring Security core plugin . And actually, we often save password hash instead of its encryption.

If you need a complete authentication and authorization solution +1 for spring security core plugin. If you just want to encrypt a domain class or parts of it in the DB, go for http://www.grails.org/plugin/crypto .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM