我正在构建一个 php 应用程序,用户需要先登录
这些登录凭据将与 WordPress 登录凭据相同
我正在尝试将应用程序与 WordPress 数据库表“users”连接,其中我们有“user_login”和“user_pass”,对我来说问题是“user_pass”列使用前缀“$S$B”加密,并且我了解到wordpress采用单边md5加密方式,无法解密。 。 。
现在我想验证我的外部应用程序的密码
我尝试过使用这个
$password = clean($_POST['password']);
$pass = "$P$B" .md5($password);
但这不起作用
谁能帮帮我
最佳答案
到目前为止,我是一个软件 wp,使用函数 wp_hash_password($passowrd) 来加密密码。 请检查功能:
/**
* Create a hash (encrypt) of a plain text password.
*
* For integration with other applications, this function can be overwritten to
* instead use the other package password checking algorithm.
*
* @since 2.5
* @global object $wp_hasher PHPass object
* @uses PasswordHash::HashPassword
*
* @param string $password Plain text user password to hash
* @return string The hash string of the password
*/
function wp_hash_password($password) {
global $wp_hasher;
if ( empty($wp_hasher) ) {
require_once( ABSPATH . 'wp-includes/class-phpass.php');
// By default, use the portable hash from phpass
$wp_hasher = new PasswordHash(8, TRUE);
}
return $wp_hasher->HashPassword($password);
}
遵循函数HashPassword($password); 尝试在您的应用程序中使用 WordPress 的登录 API。
关于php - 使用 WordPress 登录凭据的外部应用程序登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19275662/