SA-MP Forums Archive
change pass - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: change pass (/showthread.php?tid=655200)



change pass - CaptainBoi - 15.06.2018

hi i m on mysql i made an password change command its actually changing the password but its not hashing the password pls help here the code
PHP код:
CMD:changepass(playerid,params[]) 
{
    new 
Query[100], pass[200];
    if(
sscanf(params"s[200]"pass)) return Usage(playerid"/changepass [password]");
    if(
strlen(pass) < || strlen(pass) > 12) return Error(playerid"Incorrect Password length");
    
SHA256_PassHash(passpInfo[playerid][Salt], pInfo[playerid][Password], 65);
    
pInfo[playerid][Password] = pass;
    
mysql_format(DatabaseQuerysizeof(Query), "UPDATE `users` SET `Password` = '%e'  WHERE `pID` =%d LIMIT 1"pInfo[playerid][Password], pInfo[playerid][pID]);
    
mysql_tquery(DatabaseQuery,"","");
    
format2(playeridCOLOR_LIGHTGREEN"Your password has been successfully changed to (%s)"str);
    return 
1;




Re: change pass - jlalt - 15.06.2018

https://sampwiki.blast.hk/wiki/SHA256_PassHash

Third parameter is the returned hash, first parameter is const so don't assign the third parameter to the 1st parameter.

PHP код:
CMD:changepass(playerid,params[])  

    new 
Query[100], pass[200]; 
    if(
sscanf(params"s[200]"pass)) return Usage(playerid"/changepass [password]"); 
    if(
strlen(pass) < || strlen(pass) > 12) return Error(playerid"Incorrect Password length"); 
    
SHA256_PassHash(passpInfo[playerid][Salt], pInfo[playerid][Password], 65); 
    
//pInfo[playerid][Password] = pass; 
    
mysql_format(DatabaseQuerysizeof(Query), "UPDATE `users` SET `Password` = '%e'  WHERE `pID` =%d LIMIT 1"pInfo[playerid][Password], pInfo[playerid][pID]); 
    
mysql_tquery(DatabaseQuery,"",""); 
    
format2(playeridCOLOR_LIGHTGREEN"Your password has been successfully changed to (%s)"str); 
    return 
1

pass has the normal password.
pInfo[playerid][Password] has the hashed password.


Re: change pass - CaptainBoi - 15.06.2018

i tried this already this still not hashing on starting i made this code but after that thought that this would work but both not working


Re: change pass - jlalt - 15.06.2018

Quote:
Originally Posted by CaptainBoi
Посмотреть сообщение
i tried this already this still not hashing on starting i made this code but after that thought that this would work but both not working
Have you tested it or responding according to old tests? If its the second answer, please try once more.


Re: change pass - CaptainBoi - 15.06.2018

sorry dude i didnot tested it but after testing i saw it worked thanks alot
+rep


Re: change pass - CaptainBoi - 15.06.2018

still not fixed help pls


Re: change pass - Beckett - 15.06.2018

Print password (local variable and the enumerator variable) and the hash, show us the results afterwards.


Re: change pass - CaptainBoi - 15.06.2018

PHP код:
[21:23:38real password changed to progamers
[21:23:38hash password changed to progamers 
i did that and its not hashing the password still
as u see the logs


Re: change pass - jlalt - 15.06.2018

Your query text is 60 char and your password is 65 char thats 125 while you mysql query size is 100, increase this value and retry the code I posted.

PHP код:
CMD:changepass(playerid,params[])   
{  
    new 
Query[200], pass[200];  
    if(
sscanf(params"s[200]"pass)) return Usage(playerid"/changepass [password]");  
    if(
strlen(pass) < || strlen(pass) > 12) return Error(playerid"Incorrect Password length");  
    
SHA256_PassHash(passpInfo[playerid][Salt], pInfo[playerid][Password], 65);  
    
//pInfo[playerid][Password] = pass;  
    
mysql_format(DatabaseQuerysizeof(Query), "UPDATE `users` SET `Password` = '%e'  WHERE `pID` =%d LIMIT 1"pInfo[playerid][Password], pInfo[playerid][pID]);  
    
mysql_tquery(DatabaseQuery,"","");  
    
format2(playeridCOLOR_LIGHTGREEN"Your password has been successfully changed to (%s)"str);  
    return 
1;  




Re: change pass - CaptainBoi - 15.06.2018

thanks after increasing query it worked