How to use SHA256 in UCP Login on PHP?
#1

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 ?
Reply
#2

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
Reply
#3

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)
    {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)