Password encryption - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Password encryption (
/showthread.php?tid=85505)
Password encryption -
Sergei - 07.07.2009
Hello.
I've got a little problem with password encryption.
I'm using ****** 'Encrypt' to encrypt passwords which are saved in ini. I have already added encrypt thing for registering account and changing password, but I can't find where to add that for login.
Login looks like this:
pawn Код:
public OnPlayerLogin(playerid,password[])
{
new string2[128];
format(string2, sizeof(string2), "main/Accounts/%s.ini", PlayerName(playerid));
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
//other stuff
}
fclose(UserFile);
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Incorrect password!");
fclose(UserFile);
return 1;
}
return 1;
}
So where do I need to add 'Encrypt(string[])' in this case?
Thanks for help
Re: Password encryption -
Chaprnks - 07.07.2009
Try this, not sure on it so test before you use.
pawn Код:
public OnPlayerLogin(playerid,password[])
{
new string2[128];
format(string2, sizeof(string2), "main/Accounts/%s.ini", PlayerName(playerid));
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
Encrypt(password);
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
//other stuff
}
fclose(UserFile);
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Incorrect password!");
fclose(UserFile);
return 1;
}
return 1;
}
Re: Password encryption -
Sergei - 07.07.2009
It works. Thank you.