Help with changepass command.
#1

Hi, I have made this changepass command but when I use it in-game I always get wrong password. There is something wrong with the hashing.
pawn Код:
CMD:changepass(playerid, params[])
{
    new str[128], pass[129], params2[129];
    if(!Info[playerid][Logged]) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in.");
    if(sscanf(params, "s[129]s[129]", params, params2)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changepass (old password) (new password)");
    if(strlen(params2) < 3 || strlen(params2) > 24) return SendClientMessage(playerid, COLOR_RED, "Incorrect Password Length. Please choose a password between 4 and 20 characters.");
    WP_Hash(pass, sizeof(pass), params);
    if(!strcmp(pass, params))
    {
        WP_Hash(pass, sizeof(pass), params2);
        new INI:File = INI_Open(UserPath(playerid ));
        INI_SetTag(File, "Player Data");
        INI_WriteString(File, "Password", pass);
        INI_Close(File);
        format(str, sizeof(str), "You change your password to '%s'", params2);
        SendClientMessage(playerid, COLOR_GREEN, str);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password. Please try again.");
    return 1;
}
Reply
#2

if(!strcmp(pass, params)) You compare hash with inserted password This two are not same
Reply
#3

How could I fix it?
Reply
#4

Do you Have Anyvariable for Password such as pInfo[playerid][Pass] and all... ?
if u have then use this one

pawn Код:
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass,pInfo[playerid][Pass]))
{
 ///Code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)