我在sa-mp上有一个哈希函数
new MyHash[256];
SHA256_PassHash(inputtext, "78sdjs86d2h", MyHash, sizeof(MyHash));
if(!strcmp(MyHash, PlayerInfo[playerid][pKey]))
我假设78sdjs86d2h是盐,但我如何在PHP中设置salt?
我正在使用这段代码,但是哈希却没有我的盐。
if(isset($_POST['username']) && isset($_POST['password'])){
mysql_query('SET NAMES utf8');
$var = mysql_real_escape_string("\xbf\x27 OR 1=1 /*");
$username = mysql_real_escape_string($_POST['username']);
$parola = mysql_real_escape_string($_POST['password']);
$hash = hash('sha256', $parola);
$check = get_row("SELECT ID FROM players WHERE Name='$username' && password='$hash' LIMIT 1");
if(isset($check['ID']))
{
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$id = $check['ID'];
header("location: index.php");
}
else
{
printf("%s", $hash);
$err = 'Username sau parola incorecte';
}
}
如何用自己的盐哈希?
答案 0 :(得分:-1)
更新:尝试这种方式
$username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
$password1 = $_POST['password'];
$salt = '78sdjs86d2h';
$parola = hash('sha256', $password1 . $salt);
结果:33ca067dc70ef75fc1a1107f4345f3a819ecca657d3d9646d26822fd691cd10c 原文:BFD2832240F5FC1FD12004634EBE9FDE97BD0D4690695DFAC1350D0AE037398F