For password identification
#1

Hi, i have problem

I input proper password, but don't identification it as good password, although hi are good password

okey i show my code

data writing
Код:
INI_WriteInt(File,"Password",udb_hash(inputtext));
data reading
Код:
INI_Int("Password",PlayerData[playerid][pPassword]);
and data identification
Код:
if(udb_hash(inputtext) == PlayerData[playerid][pPassword])
{
// login 
}
else
{
// wrong
}
Reply
#2

I'm not familiar with the syntax of that INI include, but you probably need to use string functions like INI_WriteString or INI_String! INT functions are for integers (numbers) as the name might suggest.
Reply
#3

It's not
pawn Код:
if(udb_hash(inputtext) == PlayerData[playerid][pPassword])
It's with string compare, because they are both strings.
pawn Код:
if(strcmp(udb_hash(inputtext),PlayerData[playerid][pPassword]) == 0)
Reply
#4

Writing:

Код:
INI_WriteString(File,"Password",udb_hash(inputtext));
Reading:

Код:
INI_ReadString(PlayerData[playerid][pPassword],"Password", 20);
Reply
#5

Might be worth noting that the udb_hash (which I do not recommende using) function creates integer output only ...
Reply
#6

Can you give my exsample not hash password, just input text.

Thanks
Reply
#7

I do now using input text no hash, but now it's same like before


data identification

if(strcmp(PlayerData[playerid][pPassword],inputtext,true))

data load

INI_String("Password",PlayerData[playerid][pPassword],24);

It's still not work, what a should to do ?
Reply
#8

strcmp function returns 0 if the strings passed to the function match. Also, you should check the case sensitivity of the password, changing the bool: ignore_case parameter to false.
pawn Код:
if( !strcmp( PlayerData[ playerid ][ pPassword ], inputtext, false ) )
{
   // Load data
}
Also, I highly recommend you hash/encrypt your passwords.
Reply
#9

Thanks guys, spelially to Grim_
I fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)