change pass
#1

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;

Reply
#2

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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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

still not fixed help pls
Reply
#7

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

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
Reply
#9

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;  

Reply
#10

thanks after increasing query it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)