MySQL password hash -
Kraeror - 18.05.2018
Hello guys, I'm using the last version of MySQL (R41-4). I want to hash the password with the same hash of php language. How can the server write in the table and how can the server read it? Can you give me an example?
Re: MySQL password hash -
Logic_ - 18.05.2018
In PHP, just use the function to make your password hash in upper-case.
SA-MP has SHA2(56) which PHP has too, you can use that.
Re: MySQL password hash -
Kraeror - 18.05.2018
I know about that but are they compatible? And what is the function which I have to use for reading it from the table (I know the uploading code, but not for reading)!
Re: MySQL password hash -
Kraeror - 18.05.2018
ANY HELP PLEASE !!!
Re: MySQL password hash -
kovac - 18.05.2018
I would suggest you to use Whirlpool hash.
In PHP you can use the following:
hash("whirlpool", $string);
Tutorial for in game:
https://sampforum.blast.hk/showthread.php?tid=570945
Re: MySQL password hash -
Kraeror - 18.05.2018
Quote:
Originally Posted by kovac
|
Thank you but can you tell me how to dehash the hash, because I need it for user system (for checking if the password you wrote is correct I have to dehash it)!
Re: MySQL password hash -
CodeStyle175 - 18.05.2018
hash point is to be un reversable, you dont have to see others passwords, to steal their fb account
Re: MySQL password hash -
kovac - 18.05.2018
Quote:
Originally Posted by CodeStyle175
hash point is to be un reversable, you dont have to see others passwords, to steal their fb account
|
I don't think he meant it that way.
You can't and don't need to dehash it, only compare
PHP код:
case DIALOG_LOGIN:
{
if(response)
{
new query[500], HashedPW[130];
WP_Hash(HashedPW, sizeof(HashedPW), inputtext);
mysql_format(Database, query, sizeof(query), "SELECT * FROM userdata WHERE User='%e' AND Password='%e'", GetName(playerid), HashedPW);
mysql_tquery(Database, query, "OnUserLogin", "d", playerid);
}
else
Kick(playerid);
return 1;
}
case DIALOG_REGISTER:
{
if(response)
{
new query[500], HashedPW[130], GPCI[128];
gpci(playerid, GPCI, sizeof(GPCI));
WP_Hash(HashedPW, sizeof(HashedPW), inputtext);
mysql_format(Database, query, sizeof(query), "INSERT INTO `userdata` (`User`,`Password`,`RegisterIP`, `CreatedOn`, `GPCI`) VALUES ('%e', '%e', '%e', NOW(), '%e')", GetName(playerid), HashedPW, Player_IP[playerid], GPCI);
mysql_tquery(Database, query, "OnUserRegister", "d", playerid);
}
else
Kick(playerid);
return 1;
}
Re: MySQL password hash -
Kraeror - 18.05.2018
Quote:
Originally Posted by CodeStyle175
hash point is to be un reversable, you dont have to see others passwords, to steal their fb account
|
I don't need to see their password... I need to check it for login...
Re: MySQL password hash -
Kraeror - 18.05.2018
Quote:
Originally Posted by kovac
I don't think he meant it that way.
You can't and don't need to dehash it, only compare
PHP код:
case DIALOG_LOGIN:
{
if(response)
{
new query[500], HashedPW[130];
WP_Hash(HashedPW, sizeof(HashedPW), inputtext);
mysql_format(Database, query, sizeof(query), "SELECT * FROM userdata WHERE User='%e' AND Password='%e'", GetName(playerid), HashedPW);
mysql_tquery(Database, query, "OnUserLogin", "d", playerid);
}
else
Kick(playerid);
return 1;
}
case DIALOG_REGISTER:
{
if(response)
{
new query[500], HashedPW[130], GPCI[128];
gpci(playerid, GPCI, sizeof(GPCI));
WP_Hash(HashedPW, sizeof(HashedPW), inputtext);
mysql_format(Database, query, sizeof(query), "INSERT INTO `userdata` (`User`,`Password`,`RegisterIP`, `CreatedOn`, `GPCI`) VALUES ('%e', '%e', '%e', NOW(), '%e')", GetName(playerid), HashedPW, Player_IP[playerid], GPCI);
mysql_tquery(Database, query, "OnUserRegister", "d", playerid);
}
else
Kick(playerid);
return 1;
}
|
Thanks a lot I will try +REP!!!