MySQL password hash
#1

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

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

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)!
Reply
#4

ANY HELP PLEASE !!!
Reply
#5

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

Quote:
Originally Posted by kovac
Посмотреть сообщение
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
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)!
Reply
#7

hash point is to be un reversable, you dont have to see others passwords, to steal their fb account
Reply
#8

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(HashedPWsizeof(HashedPW), inputtext);
                
mysql_format(Databasequerysizeof(query), "SELECT * FROM userdata WHERE User='%e' AND Password='%e'"GetName(playerid), HashedPW);
                
mysql_tquery(Databasequery"OnUserLogin""d"playerid);
            }
              else
                
Kick(playerid);
            return 
1;
        }
        case 
DIALOG_REGISTER:
        {
            if(
response)
             {
                new 
query[500], HashedPW[130], GPCI[128];
                
gpci(playeridGPCIsizeof(GPCI));
                
WP_Hash(HashedPWsizeof(HashedPW), inputtext);
                
mysql_format(Databasequerysizeof(query), "INSERT INTO `userdata` (`User`,`Password`,`RegisterIP`, `CreatedOn`, `GPCI`) VALUES ('%e', '%e', '%e', NOW(), '%e')"GetName(playerid), HashedPWPlayer_IP[playerid], GPCI);
                
mysql_tquery(Databasequery"OnUserRegister""d"playerid);
            }
            else
                 
Kick(playerid);
            return 
1;
        } 
Reply
#9

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...
Reply
#10

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(HashedPWsizeof(HashedPW), inputtext);
                
mysql_format(Databasequerysizeof(query), "SELECT * FROM userdata WHERE User='%e' AND Password='%e'"GetName(playerid), HashedPW);
                
mysql_tquery(Databasequery"OnUserLogin""d"playerid);
            }
              else
                
Kick(playerid);
            return 
1;
        }
        case 
DIALOG_REGISTER:
        {
            if(
response)
             {
                new 
query[500], HashedPW[130], GPCI[128];
                
gpci(playeridGPCIsizeof(GPCI));
                
WP_Hash(HashedPWsizeof(HashedPW), inputtext);
                
mysql_format(Databasequerysizeof(query), "INSERT INTO `userdata` (`User`,`Password`,`RegisterIP`, `CreatedOn`, `GPCI`) VALUES ('%e', '%e', '%e', NOW(), '%e')"GetName(playerid), HashedPWPlayer_IP[playerid], GPCI);
                
mysql_tquery(Databasequery"OnUserRegister""d"playerid);
            }
            else
                 
Kick(playerid);
            return 
1;
        } 
Thanks a lot I will try +REP!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)