grails - Jailspt插件具有grails的加密/解密

标签 grails encryption

通过问题Is it possible to use the Grails Jasypt plugin outside the GORM layer for simple String encryption and decryption?的引用

我尝试将其用于我的密码加密/解密。
但是每次给同一个密码赋予不同的加密值。那么我如何使用以下代码和jasypt配置呢?

def authenticate(){
def jasyptConfig = grailsApplication.config.jasypt
org.jasypt.encryption.pbe.StandardPBEStringEncryptor stringEncryptor = 
       new org.jasypt.encryption.pbe.StandardPBEStringEncryptor(jasyptConfig)

def encrypted = stringEncryptor.encrypt(params.password)


}

jasypt {
algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC"
providerName = "BC"
password = "test"
keyObtentionIterations = 1000

}

最佳答案

盐!

如果您不在乎,只需将ZeroSaltGenerator实例设置为您的Encryptor。默认情况下,它是RandomSaltGenerator,因此输出是不同的。

关于grails - Jailspt插件具有grails的加密/解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21878690/

相关文章:

grails - 客户端无权以该发送者的身份发送(办公室365,grails)

grails - Grails Spock测试特定异常

android - 如何在Android项目中加入bouncy caSTLe算法

java - Sun 是否为 XML-Enc 规范提供了 Java API?

ruby-on-rails - 在 Ruby on Rails 中验证 Django 密码给出不匹配的密码

java - java中使用ECC加密图像

json - 在Groovy中渲染JSON

grails - Grails Multi-Tenancy 和Spring Security Core插件

grails - 异步发送电子邮件

encryption - 如何使用Flutter和Dart执行文件加密