Need help with Whirpool hashing
#1

Well, I decided that I need to start hashing the user's passwords and I want to make it as painless as possible for the players.

Anyways, I want the current passwords from players to be switched to Whirpool standard. The login for the first time (while it's still using the old un-hashed system) works, but after that it doesn't.

Here's my OnPlayerLogin code

pawn Код:
public OnPlayerLogin(playerid,password[])
{
    new string2[128];
    format(string2, sizeof(string2), "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);
        }
        new password2[129];
        if(strlen(PlayerInfo[playerid][pKey]) > 20)
        {
            WP_Hash(password2, sizeof (password2), password);
        }
        else
        {
            format(password2, 129, "%s", password);
        }
        if(strcmp(PlayerInfo[playerid][pKey],password2, true ) == 0 )
        {
                new key[ 256 ] , val[ 256 ];
                new Data[ 256 ];
                while ( fread( UserFile , Data , sizeof( Data ) ) )
                { ...
And this is my saving callback

pawn Код:
new filestring[256];
            format(filestring, sizeof(filestring), "Accounts/%s.ini", PlayerName(playerid));
            if(PlayerInfo[playerid][pUpdated] != 17 && fexist(filestring)) // Change this from time to time
            {
                fremove(filestring);
                PlayerInfo[playerid][pUpdated] = 17;
                if(strlen(PlayerInfo[playerid][pKey]) < 20)
                {
                    new password2[129];
                    WP_Hash(password2, sizeof (password2), PlayerInfo[playerid][pKey]);
                    strmid(PlayerInfo[playerid][pKey], password2, 0, strlen(password2), 255);
                }
            }
            new File: hFile2 = fopen(filestring, io_write);
            if(hFile2)
            {...
I don't know what's wrong with it :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)