【发布时间】:2014-06-27 13:12:28
【问题描述】:
我在 php 服务器上使用这样的函数 crypt:
$hash = crypt($password, '$2y$10$' . $salt);
通过 Blowfish 方法对密码进行哈希处理。
我正在寻找 crypt 密码的 java 等效项。
我找到了这段代码,但我不知道在哪里添加 $salt。更多内容:
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()));
感谢您的每一个想法或回答。
【问题讨论】:
标签: java php salt blowfish crypt