[MySQL]Hash
#1

How to hash passwords ?
Here is the code...
pawn Код:
public OnPlayerLogin(playerid,password[])
{
    SendClientMessage(playerid, COLOR_WHITE, "Logging you in.");
    new string2[128], string[1024], pName[MAX_PLAYER_NAME], Escape[2][128], result[128];//keystring[256],
    pName = PlayerName(playerid);
    mysql_real_escape_string(pName, Escape[0]);
    WP_Hash(hashPassword, 129, password);
    SaveToMysql(password);
    mysql_real_escape_string(password, Escape[1]);
    format(string, sizeof(string), "SELECT * FROM players WHERE `Name`='%s' AND `Key`='%s'",Escape[0],Escape[1]);
    mysql_query_ex(string);
    mysql_store_result();
    SendClientMessage(playerid, COLOR_WHITE, "Checking your password...");
    if(mysql_num_rows() == 0)
    {
        mysql_free_result();
        SendClientMessage(playerid, COLOR_RED, "Your password is wrong!");
        ShowPlayerDialog(playerid, LOGIN_DIALOG, 1, "{3399CC}Information", "{FFFFFF}You have an account here, please type below your password to login.", "Login", "Quit");
        WrongPass[playerid]++;
        if(WrongPass[playerid]>6)
        {
            Kick(playerid);
        }
        return 1;
    }
    mysql_retrieve_row();
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=366135
Reply
#3

there's no tutorial for mysql...if somobody could help ok don't make posts for fun
Reply
#4

pawn Код:
WP_Hash(hashPassword, 129, password);
You do have Whirlpool but you don't use the hashed password (which was stored in hashPassword) anywhere. It'd be better to be a local string though.

Take a look:
pawn Код:
SaveToMysql(password);
mysql_real_escape_string(password, Escape[1]);
You escape the password and you pass it as an argument to the query when you should've used the hashed password instead.
Reply
#5

how to make change that to whirpool hashing passwords? please help
Reply
#6

I think you can hash them without whirlpool too
Quote:

All passwords are hashed with SHA1, that means you cannot decrypt SHA1 passwords once they are set. For more information, visit the Wikipedia Page
for example:
pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s', 0.0)", pname, passwordstring, IP);
sorce
Quote:

how to make change that to whirpool hashing passwords? please help

Why would you like to make changes to a player's password ?
Reply
#7

Come on..can somebody use my code and install whirepool please?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)