我想在php中创建注册页面,并使用bcrypt将密码散列并放入数据库。
我还想在Java中创建一个登录系统,并使用jbcrypt获得相同密码中的密码。
我怎样才能使jbcrypt和bcrypt在php中兼容,使用相同的盐。
发布于 2017-06-23 11:53:43
您可以查看以下内容:
https://github.com/ircmaxell/password_compat/issues/49
这对我很有效:
public static void main(String[] args) {
//Laravel bcrypt out
String hash_php = "$2y$10$ss9kwE8iSIqcJOAPhZR0Y.2XdYXJTFJ1/wGq6SUv74vULE7uhKUIO".replaceFirst("2y", "2a");
System.out.println("hash php " + hash_php);
//String a_hash = BCrypt.hashpw("123456", BCrypt.gensalt());
//System.out.println("Encrypt " + a_hash);
if (BCrypt.checkpw("123456", hash_php)) {
System.out.println("It matches");
} else {
System.out.println("It does not match");
}
//mtPruebaRecuperarClave();
}控制台- OutPut

我希望这对你有帮助。
发布于 2019-09-25 00:29:24
如果从散列中删除前7个字符($2y$10$ / $2a$10$),其余字符应该是相同的,无论您使用的是哪种编程语言。生成的散列的第一个字符是一个前缀,它告诉我们有关散列算法的更多信息。
在您的示例中,$2y$和$a2$定义了散列的算法,而10$是散列生成的“成本”(重复应用散列算法的次数或类似的东西)。
If you want to learn more about the prefixes in the bcrypt generated hashes, read this article。
https://stackoverflow.com/questions/44614380
复制相似问题