How to use SHA256 in UCP Login on PHP? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to use SHA256 in UCP Login on PHP? (
/showthread.php?tid=602141)
How to use SHA256 in UCP Login on PHP? -
Metharon - 02.03.2016
Ok so i'm having this hash function on sa-mp
Код:
new MyHash[256];
SHA256_PassHash(inputtext, "78sdjs86d2h", MyHash, sizeof(MyHash));
if(!strcmp(MyHash, PlayerInfo[playerid][pKey]))
I assume 78sdjs86d2h is the salt, but the question is how do i set the salt in php ?
Right now i did this and seems to work, it hash but not with my salt...
Код HTML:
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';
}
}
How do i make it to hash with my own salt ?
Re: How to use SHA256 in UCP Login on PHP? -
Metharon - 02.03.2016
UPDATE: Tried this way
Код:
$username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
$password1 = $_POST['password'];
$salt = '78sdjs86d2h';
$parola = hash('sha256', $password1 . $salt);
The result: 33ca067dc70ef75fc1a1107f4345f3a819ecca657d3d9646d2 6822fd691cd10c
The original: BFD2832240F5FC1FD12004634EBE9FDE97BD0D4690695DFAC1 350D0AE037398F
Re: How to use SHA256 in UCP Login on PHP? -
Metharon - 03.03.2016
FIXED
pawn Код:
$salt = '78sdjs86d2h';
$username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
$password = mysqli_real_escape_string($DB_H, addslashes($_POST['password']));
$hash1 = hash('sha256', $password . $salt);
$hash = strtoupper($hash1);
$check = mysqli_query($DB_H, "SELECT * FROM players WHERE Name='$username' && Password = '$hash'");
if(mysqli_num_rows($check) != 0)
{