没有这样的算法 - bcrypt

No such algorithm - bcrypt

我正在使用 Spring 安全和 bcrypt 来保证密码安全。

它实际上是在 Grails 应用程序中。当应用程序启动时,我得到:

"No such algorithm [bcrypt]"

我将错误追踪到 Spring security:

中的代码
    try {
        return MessageDigest.getInstance(algorithm);
    }
    catch (NoSuchAlgorithmException e) {
        throw new IllegalArgumentException("No such algorithm [" + algorithm + "]");
    }

如何将 bcrypt 安装到 Java 安全性中?

我是 运行 Oracle JDK 1.8.0_73-b02 在 CentOS 7.

问题出在代码上:

messageDigestPasswordEncoder(MessageDigestPasswordEncoder, conf.password.algorithm) {
    encodeHashAsBase64 = conf.password.encodeHashAsBase64
    iterations = conf.password.hash.iterations
}

默认情况下,Grails 3 spring-核心插件配置 conf.password.algorithm="bcrypt"

我以为我已经在我的配置中覆盖了它,但那是在 Config.groovy 中。在 grails 3 中,配置需要移动到 application.groovy