[MYSQL]Whirlpool hashing cant get to work
#1

Ok so i want the passwords to be hashed... But it aint working this is my code:
Register dialog part:
pawn Код:
Dialog_Register(playerid, response, inputtext[])
{
    switch(response)
    {
        case 1:
        {
            new hashPassword[129];
            if(AccountExists[playerid])
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already registered!");

            if(APlayerData[playerid][PlayerLogged] == 1)
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already logged in!");

            if(strlen(inputtext) < 3 || strlen(inputtext) >= 32)
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your password is too short or too long!");
            CheckMySQL();
            new string[128];
            WP_Hash(hashPassword, 129, inputtext);
            format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", APlayerData[playerid][Name], inputtext);
            mysql_query(string);

            AccountExists[playerid] = 1;
            SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your account has been created, please login now!");

            ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "Welcome to European Roleplay", "Welcome to ER please login in order to play", "Login", "Cancel");
        }
        case 0:
        {
            Kick(playerid);
        }
    }
    return 1;
}
Dialog login
pawn Код:
Dialog_Login(playerid, response, inputtext[])
{
    switch(response)
    {
        case 1:
        {
            if(!AccountExists[playerid])
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're not registered!");

            if(APlayerData[playerid][PlayerLogged] == 1)
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already logged in!");

            if(strlen(inputtext) < 3 || strlen(inputtext) >= 32)
            {
                SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your password is too short or too long!");
                Kick(playerid);
            }

            CheckMySQL();

            new string[128], hashPassword[129];
            format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", APlayerData[playerid][Name], inputtext);
            mysql_query(string);
            mysql_store_result();

            if(!mysql_num_rows())
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Incorrect password!"), Kick(playerid);
            WP_Hash(hashPassword, 129, inputtext);
            new row[128]; // The length of 1 'row' total.
            new field[14][128]; // [4] = Amount of fields, [24] = Max length of the bigest field.

            mysql_fetch_row_format(row, "|");
            explode(row, field, "|");
            mysql_free_result();

            // The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
            APlayerData[playerid][Name] = strval(field[1]);
            format(APlayerData[playerid][Password], 32, "%s", field[2]);
            APlayerData[playerid][Admin] = strval(field[3]);
            APlayerData[playerid][Money] = strval(field[4]);
            APlayerData[playerid][X] = strval(field[5]);
            APlayerData[playerid][Y] = strval(field[6]);
            APlayerData[playerid][Z] = strval(field[7]);
            APlayerData[playerid][Rot] = strval(field[8]);
            APlayerData[playerid][Score] = strval(field[9]);
            APlayerData[playerid][Points] = strval(field[10]);
            format(APlayerData[playerid][pAccent], 19, "%s", field[11]);
            APlayerData[playerid][Houses] = strval(field[12]);
            APlayerData[playerid][Paydays] = strval(field[13]);
            GivePlayerMoney(playerid, APlayerData[playerid][Money]);
            SetPlayerScore(playerid, APlayerData[playerid][Score]);


            format(string, sizeof(string), "[ACCOUNT] Welcome back %s, you are now logged in!", APlayerData[playerid][Name]);
            SendClientMessage(playerid, 0xFF0000, string);

            APlayerData[playerid][PlayerLogged] = 1;
        }
        case 0:
        {
            Kick(playerid);
        }
    }

    return 1;
}
Thanks in advance
Reply
#2

pawn Код:
format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", APlayerData[playerid][Name], inputtext);
is what you did, not using the hashed password
you would use your hashPassword to save it hashed because you did WP_Hash(hashPassword, 129, inputtext);


format(APlayerData[playerid][Password], 32, "%s", field[2]);
is how/where we store their password from the mysql stuff right?
and
WP_Hash(hashPassword, 129, inputtext);
is where we hash the password they typed

I surmise it would be something like this after you load it...
pawn Код:
if(!strcmp(hashedPassword, field[2], false)) //false being case sensitive
{
    //we load their other stuff / log them in
}
else
{
    //they got it wrong
}
Reply
#3

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
format(string, sizeof(string), "INSERT INTO Users (Name,Password) VALUES ('%s','%s')", APlayerData[playerid][Name], inputtext);
is what you did, not using the hashed password
you would use your hashPassword to save it hashed because you did WP_Hash(hashPassword, 129, inputtext);


format(APlayerData[playerid][Password], 32, "%s", field[2]);
is how/where we store their password from the mysql stuff right?
and
WP_Hash(hashPassword, 129, inputtext);
is where we hash the password they typed

I surmise it would be something like this after you load it...
pawn Код:
if(!strcmp(hashedPassword, field[2], false)) //false being case sensitive
{
    //we load their other stuff / log them in
}
else
{
    //they got it wrong
}
yes thats where its saved...
Reply
#4

Ok so i compile the GM with the native in it from whirlpool on windows. But my server is linux. Could that be the problem?
Reply
#5

Bumpy pumpy i need help
Reply
#6

Bump :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)