问题描述
在 sha_pass_hash
字段 has been removed 之后验证 AzerothCore 帐户(制作盐和验证器)的 PHP 算法是什么?
在我们使用之前:
$sha_pass_hash = getpasswordHash($account_name,$password);
现在怎么样了?如何制作salt和verifier来注册新账号?
谁能提供一些详细的示例说明?
解决方法
我刚刚为这里的 acore-cms 做了 https://github.com/azerothcore/acore-cms/pull/20/files
我什至发布了快速查看代码以使用盐计算密码:
function CalculateSRP6Verifier($username,$password,$salt)
{
// algorithm constants
$g = gmp_init(7);
$N = gmp_init('894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7',16);
// calculate first hash
$h1 = sha1(strtoupper($username . ':' . $password),TRUE);
// calculate second hash
$h2 = sha1($salt.$h1,TRUE);
// convert to integer (little-endian)
$h2 = gmp_import($h2,1,GMP_LSW_FIRST);
// g^h2 mod N
$verifier = gmp_powm($g,$h2,$N);
// convert back to a byte array (little-endian)
$verifier = gmp_export($verifier,GMP_LSW_FIRST);
// pad to 32 bytes,remember that zeros go on the end in little-endian!
$verifier = str_pad($verifier,32,chr(0),STR_PAD_RIGHT);
return $verifier;
}
记得安装 php-gmp 库。
如果您需要创建一个帐户,您可以使用它来生成盐:
// generate a random salt
$salt = random_bytes(32);
这些代码受到 MasterKing32 CMS 的强烈启发。