udb_hash: argument type mismatch
#1

Код:
saonline.pwn(409) : error 035: argument type mismatch (argument 1)
saonline.pwn(411) : error 035: argument type mismatch (argument 2)
pawn Код:
CMD:changepass(playerid,params[])
{
    new oldpass[32],
        newpass[32];
       
    if(sscanf(params, "s[32]s[32]", oldpass, newpass)) return SendClientMessage(playerid, -1, "{3685BA}Usage: {FFFFFF}/changepass [old password] [new password]");
    if(!strcmp(udb_hash(oldpass), udb_hash(newpass))) //l. 409
    {
        if(!strcmp(PlayerInfo[playerid][pPass], udb_hash(newpass))) return SendClientMessage(playerid, -1,"{3685BA}Error: {FFFFFF}Your current password equals the new password.");//l. 411
        format(PlayerInfo[playerid][pPass], 32, newpass);
        SendClientMessage(playerid, -1, "{3685BA}SERVER: {FFFFFF}You have successfully changed your password.");
    }
    else
    {
        SendClientMessage(playerid, -1,"{3685BA}SERVER: {FFFFFF}Your old password is incorrect. Please try again.");
    }
    return 1;
}
What am I doing wrong?
Reply
#2

Quote:

What am I doing wrong?

by using strcmp

try this

PHP код:
CMD:changepass(playerid,params[])
{
    new 
oldpass[30], newpass[30], pass;
    if(
sscanf(params"s[30]s[30]"oldpassnewpass)) SendClientMessage(playerid, -1"{FFFF00}[Usage:]: {FFFFFF}/changepass [old password] [new password]");
    else if(
udb_hash(oldpass) != PlayerInfo[playerid][pPass]) SendClientMessage(playerid,-1,"Error: Your old password is incorrect, please try again.");
    else if((
pass udb_hash(newpass)) == PlayerInfo[playerid][pPass]) SendClientMessage(playerid,-1,"Error: Your new password is the current password.");
    else
    {
        new 
string[128];
        
PlayerInfo[playerid][pPass] = pass;
        
format(stringsizeof(string), "Your password is successfully changed to: %s - hash: %d"newpasspass);
        
SendClientMessage(playerid, -1string);
    }
    return 
1;

You must save this after the line
PlayerInfo[playerid][pPass] = pass;
Reply
#3

Why not use whirlpool + salt?. This method is old and likely poor
Reply
#4

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
This method is old and likely poor
It is poor. udb_hash (Adler32/CRC32) is cracked in seconds.
Reply
#5

Oh, now thanks for the heads up. I'm going for Whirlpool, then. I've never used it even though I know about it. Regardless, If I have this, how can I switch up to Whirlpool? I know it's just not 'switching', but how's it done?

pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
Reply
#6

pawn Код:
// after includes
native WP_Hash(buffer[], len, const str[]);
new buf[129]; // will be used for whirlpool hash

if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                WP_Hash(buf, sizeof(buf), inputtext);
                INI_WriteInt(File,"Password", buf); //<- also WriteInt, change it to string (sorry If I'm wrong I don't use y_ini)
Reply
#7

Yes, iZN, you must use WriteString.

Thanks for helping and for the heads up. There you go with a point, each of you.
Reply
#8

One more thing: http://pastebin.com/D9pztR5P

I have "if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])" up there, how do I change that to WP?
Reply
#9

Код:
new hashpass[128]; 
WP_Hash(hashpass,sizeof(hashpass),inputtext);

if(!strcmp(hashpass, pInfo[playerid][Pass], false)) 
            {
                 //your code goes here.
            }
Reply
#10

Thanks a lot, Rittik.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)