new string[1024];
strcat(string, "CREATE TABLE IF NOT EXISTS db_players (playerid INTEGER PRIMARY KEY AUTOINCREMENT, Username VARCHAR(24) COLLATE NOCASE, Pass VARCHAR(129) NOT NULL, salt VARCHAR(129), AdminLevel INTEGER DEFAULT 0 NOT NULL, PremiumLevel INTEGER DEFAULT 0 NOT NULL");
strcat(string, ", Experience INTEGER DEFAULT 0 NOT NULL, Level INTEGER DEFAULT 0 NOT NULL, Weapon_0 INTEGER DEFAULT 0 NOT NULL, Weapon_1 INTEGER DEFAULT 0 NOT NULL, Weapon_2 INTEGER DEFAULT 0 NOT NULL, Weapon_3 INTEGER DEFAULT 0 NOT NULL, Weapon_4 INTEGER DEFAULT 0 NOT NULL");
strcat(string, ", Kills INTEGER DEFAULT 0 NOT NULL, Deaths INTEGER DEFAULT 0 NOT NULL, DeagleKills INTEGER DEFAULT 0 NOT NULL, ShotgunKills INTEGER DEFAULT 0 NOT NULL, SniperKills INTEGER DEFAULT 0 NOT NULL, RifleKills INTEGER DEFAULT 0 NOT NULL, DuelsWon INTEGER DEFAULT 0 NOT NULL, DuelsLost INTEGER DEFAULT 0 NOT NULL)");
db_query(PlayersDB, string);
if(dialogid == D_CHANGEPASS2)
{
if(response)
{
if(!strlen(inputtext))
{
return ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_MSGBOX, "Change password [2/2]", "Type in your new password\nERROR: You must enter a password", "Confirm", "Cancel"); // showing player the dialog to enter his correct and current password
}
if(!IsValidPassword(inputtext))
{
ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_PASSWORD, "Change password [2/2]", "Type in your new password\nERROR: The password is invalid, Valid characters are: A-Z, a-z, 0-9 ", "Confirm", "Cancel");
}
if(strlen(inputtext) < 3 || strlen(inputtext) > 24)
{
ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_PASSWORD, "Change password [2/2]", "Type in your new password.\nERROR: The password is invalid, Its length should be 3-24 characters", "Confirm", "Cancel");
}
SHA256_PassHash(inputtext, User[playerid][Salt], User[playerid][Password], 129);
new Query2[1024];
new string[128];
format(Query2, sizeof(Query2), "UPDATE db_players SET Pass = %q WHERE Username = %q", User[playerid][Salt], User[playerid][Password], 129, DB_Escape(Player[playerid][GlobalName]));
db_query(PlayersDB, Query2);
format(string, sizeof(string), "Your new password is: %s", inputtext);
ShowPlayerDialog(playerid, D_INFO, DIALOG_STYLE_MSGBOX, "Password changed!", string, "Confirm", "Cancel");
return 1;
}
}
UPDATE db_players SET Pass = '%q' WHERE Username = '%q'
new passwordlen = strlen(inputtext); // get length once if(!passwordlen) { return ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_MSGBOX, "Change password [2/2]", "Type in your new password\nERROR: You must enter a password", "Confirm", "Cancel"); // showing player the dialog to enter his correct and current password } if(!IsValidPassword(inputtext)) { ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_PASSWORD, "Change password [2/2]", "Type in your new password\nERROR: The password is invalid, Valid characters are: A-Z, a-z, 0-9 ", "Confirm", "Cancel"); return 1; // you are missing return here, otherwise password will still get updated } if(passwordlen < 3 || passwordlen > 24) { ShowPlayerDialog(playerid, D_CHANGEPASS, DIALOG_STYLE_PASSWORD, "Change password [2/2]", "Type in your new password.\nERROR: The password is invalid, Its length should be 3-24 characters", "Confirm", "Cancel"); return 1; // you are missing return here, otherwise password will still get updated }
Код:
SHA256_PassHash(inputtext, User[playerid][Salt], User[playerid][Password], 129); |
Код:
strcat(string, "CREATE TABLE IF NOT EXISTS db_players (playerid INTEGER PRIMARY KEY AUTOINCREMENT, Username VARCHAR(24) COLLATE NOCASE, Pass VARCHAR(129) NOT NULL, salt VARCHAR(129), AdminLevel INTEGER DEFAULT 0 NOT NULL, PremiumLevel INTEGER DEFAULT 0 NOT NULL"); |
Код:
format(Query2, sizeof(Query2), "UPDATE db_players SET Pass = %q WHERE Username = %q", User[playerid][Salt], User[playerid][Password], 129, DB_Escape(Player[playerid][GlobalName])); |
format(Query2, sizeof(Query2), "UPDATE db_players SET Pass = '%q' WHERE Username = '%q'", User[playerid][Password], Player[playerid][GlobalName]);
if i hash a password doesn't matter what method i use whether it be udb, wp or SHA256 SQL this occurs...
|
Many thanks bud, All works well now! And I have migrated to bcrypt. I hope it was worth it.
|