SAMP SHA_256 vs PHP SHA_256
#1

Hello,

I am making a password recovery system, by simply clicking a link the user password will be set to 'RANDOMGENERATEDSTRING' + Salt from database. The random generated string will be sent to the users email account.

SO, this is how the new password + old salt is used to create and set the new password

PHP код:
$newPasswordUnhashed generateRandomString();
$result mysqli_query($connection"SELECT Salt FROM users WHERE Name='" $name "'");
$row mysqli_fetch_assoc($result);
$salt $row['Salt'];
if(
$salt == null)
{
    exit(
"Couldn't receive salt.");
}
$newPassword hash('sha256'$newPasswordUnhashed $salt);
if(!
mysqli_query($connection"UPDATE users SET Password='" $newPassword ."' WHERE Name='" $name "'")) {
    exit(
"Unable to set new temporary password.");

and this is my samp login:

PHP код:
forward loginPlayer(playeridenteredPassword[]);
public 
loginPlayer(playeridenteredPassword[])
{
    new 
password[65];
    new 
salt[11];
    
cache_get_value_name(0"Password"password);
    
cache_get_value_name(0"Salt"salt);
    new 
passwordToCheck[65];
    
SHA256_PassHash(enteredPasswordsaltpasswordToChecksizeof(passwordToCheck));
    if(!
strcmp(passwordpasswordToCheckfalsestrlen(password)))
    {
        
loadProfile(playerid);
        return 
true;
    }
    
    
ShowPlayerDialog(playeridLOGIN_DIALOGDIALOG_STYLE_PASSWORD"Log into your account""Please enter your password to log into your account.""Login""Exit");
    return 
false;

Both hash functions seem to reutnr something else, i have no clue why, can anyone help me?

greetings Marcel
Reply


Messages In This Thread
SAMP SHA_256 vs PHP SHA_256 - by BiosMarcel - 18.12.2016, 20:04
Re: SAMP SHA_256 vs PHP SHA_256 - by Vince - 18.12.2016, 20:32
Re: SAMP SHA_256 vs PHP SHA_256 - by BiosMarcel - 18.12.2016, 20:35

Forum Jump:


Users browsing this thread: 1 Guest(s)