Register and Login
#1

Hey, i made my register and login system and its working no errors but when i type my password its saved and i try to login and it says false password. My ondialog response:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTRACIJA:
        {
            new servermemorija[128], igraci[MAX_PLAYER_NAME];
            GetPlayerName(playerid, igraci, sizeof(igraci));
            format(servermemorija, sizeof(servermemorija), "/Igraci/%s.ini", igraci);
            if(!response)return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))return ShowPlayerDialog(playerid, DIALOG_REGISTRACIJA, DIALOG_STYLE_INPUT, "Registracija", "Dobrodosao na Beogradski Sindikat.\n\nNalog: Nije pronadjen.\n\nUpisite vas password za registraciju.", "Ok", "Odustani");
                dini_Create(servermemorija);
                dini_IntSet(servermemorija, "Lozinka", udb_hash(inputtext));
                dini_IntSet(servermemorija, "Admin", StatsIgraca[playerid][Admin]);
                dini_IntSet(servermemorija, "Novac", StatsIgraca[playerid][Novac]);
                dini_IntSet(servermemorija, "Level", StatsIgraca[playerid][Level]);
                StatsIgraca[playerid][Admin] = dini_Int(servermemorija, "Admin");
                StatsIgraca[playerid][Novac] = dini_Int(servermemorija, "Novac");
                StatsIgraca[playerid][Level] = dini_Int(servermemorija, "Level");
            }
        }
        case DIALOG_LOGIN:
        {
            new servermemorija[128], igraci[MAX_PLAYER_NAME], tmp;
            tmp = dini_Int(servermemorija, "Lozinka");
            GetPlayerName(playerid, igraci, sizeof(igraci));
            format(servermemorija, sizeof(servermemorija), "/Igraci/%s.ini", igraci);
            if(!response)return Kick(playerid);
            if(!strlen(inputtext))return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Dobrodosao na Beogradski Sindikat.\n\nNalog: Pronadjen.\n\nUpisite vas password za login.", "Ok", "Odustani");
            if(udb_hash(inputtext) != tmp)
            {
                SendClientMessage(playerid, -1, "BSRP: (( NETECAN PASSWORD ! ))");
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Dobrodosao na Beogradski Sindikat.\n\nNalog: Pronadjen.\n\nUpisite vas password za login.", "Ok", "Odustani");
            }
            else
            {
                StatsIgraca[playerid][Logovan]++;
                StatsIgraca[playerid][Admin] = dini_Int(servermemorija, "Admin");
                SetPlayerScore(playerid, StatsIgraca[playerid][Level]);
                GivePlayerMoney(playerid, dini_Int(servermemorija, "Novac")-GetPlayerMoney(playerid));
                SendClientMessage(playerid, -1, "BSRP: (( USPESAN LOGIN ! ))");
            }
        }
    }
    return 1;
}
Reply
#2

im wondering if you have this
pawn Код:
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
But i'd also like to mention this quote by ******
Quote:
Originally Posted by ******
Посмотреть сообщение
Don't use udb_hash - it's Adler32 and not secure at all!
Reply
#3

Always use https://sampwiki.blast.hk/wiki/Strcmp when checking for the correct input string.

if(strcmp(udb_hash(inputtext), tmp))
Reply
#4

What can i use insted of udb_hash i deleted it and put only inputtext but mistach
Reply
#5

Use this hashing system to make a secure password, remember to use a salt.

https://sampforum.blast.hk/showthread.php?tid=65290
Reply
#6

Now i get when i stock UDB_HASH
pawn Код:
C:\Users\matRixgameR\Desktop\Pawno\gamemodes\BSRP.pwn(14) : error 021: symbol already defined: "udb_hash"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
ist not defined/newed/stocked.
Reply
#7

Quote:
Originally Posted by MatriXgaMer
Посмотреть сообщение
Now i get when i stock UDB_HASH
pawn Код:
C:\Users\matRixgameR\Desktop\Pawno\gamemodes\BSRP.pwn(14) : error 021: symbol already defined: "udb_hash"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
ist not defined/newed/stocked.
Then it's already added inside a include. Either use it with the strcmp function or add a whirlpool hash and use the strcmp function.
Reply
#8

I used WP but didnt help at all
Reply
#9

What is wrong then? Doesn't it generate a hash, or do you mean that it doesn't recognize the password when logging in?
Reply
#10

it dosent recognize the password
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)