[MySQL]sha256 problem
#1

Im using sha256 for password hashing, but when someone chnagepassword and reconnect, it's say wrong password

changepassword command:
PHP код:
CMD:changepassword(playeridparams[])
{
    new 
query[264], string[264], newpass[64];
    if(
sscanf(params"s[64]"newpass)) return SendClientMessage(playerid, -1"Use: /changepassword [new password]");
    if(
strlen(newpass) < 5) return SendClientMessage(playerid3"The password need to be at least 5 characters.");
    
    
format(stringsizeof (string), "You've change your password in: %s.Keep it safe!"newpass);
    
SendClientMessage(playerid, -1string);
    
    for (new 
016i++) APlayerData[playerid][Salt][i] = random(94) + 33;
    
SHA256_PassHash(newpassAPlayerData[playerid][Salt], APlayerData[playerid][PlayerPassword], 65);
    
    
mysql_format(g_SQLquerysizeof query"UPDATE `players` SET `password`= '%e',`salt` = '%e' WHERE `username` = '%e'"APlayerData[playerid][PlayerPassword],APlayerData[playerid][Salt],pName(playerid));
    
mysql_tquery(g_SQLquery);
    return 
1;

It's same thing on the changeplayerpassword , but changeplayerpassword command works but changepassword coomad not
PHP код:
CMD:changeplayerpassword(playerid,params[])
{
    
LevelCheck(playerid,8);
    new 
name[MAX_PLAYER_NAME],query[264],pass[64],hasshed_password[64],salt[16];
    if(
sscanf(params,"s[24]s[64]",name,pass)) return SendClientMessage(playerid, -1"Use: /changepalyerpassword <ExactName> <password>");
    if(
strlen(pass) < 5) return SendClientMessage(playerid3"The password need to be at least 5 characters.");
    for (new 
016i++) salt[i] = random(94) + 33;
    
SHA256_PassHash(passsalthasshed_password64);
    
mysql_format(g_SQLquerysizeof(query), "UPDATE `players` SET `password` = '%e',`salt` = '%e' WHERE `username` = '%e' LIMIT 1"hasshed_password,salt,name);
    
mysql_tquery(g_SQLquery"","");
    return 
1;

I rework the comand 5 times, but never work correct , i was used temp variabiles , player variabiles but it's not work
Reply


Messages In This Thread
[MySQL]sha256 problem - by Banditul18 - 12.03.2017, 14:48
Re: [MySQL]sha256 problem - by Jefff - 12.03.2017, 15:27
Re: [MySQL]sha256 problem - by Banditul18 - 12.03.2017, 17:16
Re: [MySQL]sha256 problem - by Jefff - 12.03.2017, 17:20
Re: [MySQL]sha256 problem - by Banditul18 - 12.03.2017, 17:35
Re: [MySQL]sha256 problem - by Jefff - 12.03.2017, 20:06

Forum Jump:


Users browsing this thread: 2 Guest(s)