gpt4 book ai didi

java - 尝试使用 phpass 检查 wordpress 密码哈希

转载 作者:搜寻专家 更新时间:2023-10-31 20:17:21 25 4
gpt4 key购买 nike

我有一个散列 Wordpress 密码数据库。我正在尝试根据数据库存储的密码检查用户密码,但哈希值不正确。我正在使用 this github codeisMatch() 中进行一些登录。知道为什么这些密码不匹配吗?纯文本密码是 alberta10

  public boolean isMatch(String password, String storedHash) {
// The first 12 digits of the hash is used to modify the encryption.
String setting = storedHash.substring(0, 12);
logger.log(Level.INFO, "----Hashed pwd from db is: "+storedHash);
logger.log(Level.INFO, "----Hashed pwd using php-pass: "+encrypt(password, setting));

return storedHash.equals(encrypt(password, setting));
}

这是我的authenticate() 方法

private void authenticate(String username, String password) throws Exception {
// Throw an Exception if the credentials are invalid
PasswordHasher pwdHasher=new PasswordHasher();

_logger.log(Level.INFO, "----Authenticating user: "+username);
try{
Connection conn=authenticationBiz.connWordpressDB();
String query = "SELECT * FROM wp_users WHERE user_login = ?";
PreparedStatement preparedStmt = conn.prepareStatement(query);
preparedStmt.setString(1, username);
ResultSet rs=preparedStmt.executeQuery();
rs.next();//get first result
_logger.log(Level.INFO, "----Hashed pwd from db is: "+rs.getString("user_pass"));
if(pwdHasher.isMatch(password,rs.getString("user_pass")))
return;
}
catch(Exception e){
_logger.log(Level.INFO, "----Exception in Authenticating user: "+e);
throw e;
}
throw new Exception();
}

这是日志输出:

----Hashed pwd from db is: $P$BeatnTVG2/U8KZwpaWbPUF4yghHEKf.
17:21:40,997 INFO [com.mollom.phpass] (default task-37) ----Hashed pwd from db is: $P$BeatnTVG2/U8KZwpaWbPUF4yghHEKf.
----Hashed pwd using php-pass: $P$BeatnTVG2etvrth3rlCUdiNRm93PO9xZjXNr1f5s8izUZFfIq70V

最佳答案

原来我使用的 Github 项目不符合用于生成哈希值的初始标准。我发现:https://github.com/Wolf480pl/PHPass效果很好

关于java - 尝试使用 phpass 检查 wordpress 密码哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46008421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com