Java 中的 PHP crypt(pass, salt) 替代方案 - Blowfish 算法 [英] PHP crypt(pass, salt) alternative in Java - Blowfish algorithm

查看:60
本文介绍了Java 中的 PHP crypt(pass, salt) 替代方案 - Blowfish 算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php 服务器上使用函数 crypt,如下所示:

I'm using on php server function crypt like this:

$hash = crypt($password, '$2y$10$' . $salt);

它通过 Blowfish 方法对密码进行哈希处理.

It makes hash of password by Blowfish method.

我正在寻找 crypt 密码的 java 等价物.

I'm looking for java equivalent for crypt password.

我找到了这段代码,但我不知道在哪里添加 $salt.更多内容:

I found this code, but I don't know where add $salt. More above:

String key = "abcd";
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish");
cipher.init(cipher.ENCRYPT_MODE, keySpec);
return DatatypeConverter.printBase64Binary(cipher.doFinal(key.getBytes()));

感谢您的每一个想法或答案.

Thank's for every idea or answer.

推荐答案

现在我确实找到了一些带有河豚的 crypt(3) 的 java 实现:

Now I did found some java implementations of crypt(3) with blowfish:

http://www.mindrot.org/projects/jBCrypt/(最后更新2010)

http://docs.spring.io/spring-security/site/docs/3.2.3.RELEASE/apidocs/org/springframework/security/crypto/bcrypt/BCrypt.html

这篇关于Java 中的 PHP crypt(pass, salt) 替代方案 - Blowfish 算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆