Jump to content
  • 0

Script: Problema 'bcrypt'.


Question

Posted

Salut,

problema mea este cu hash-ul in baza de date. 'PasswordVerify => InvalidHash("")'.

 

function HashPassword(playerid) {
	if(!IsPlayerConnected(playerid)) 
		return 0;

	bcrypt_get_hash(PlayerInfo[playerid][pPassword]);

	mysql_format(SQL, gString, sizeof gString, "insert into users (Username, Password, registerDate) values ('%e', '%e', '%d')", GetName(playerid), PlayerInfo[playerid][pPassword], gettime());
	mysql_pquery(SQL, gString, "OnPlayerRegister", "d", playerid);
	return 1;
}

function PasswordVerify(playerid, bool: succes) {
    if(!IsPlayerConnected(playerid))
        return 0;

    if(!succes) {
        if(++LoginTries[playerid] >= 3) {
            SendErrorMsg(playerid, "You have entered the wrong password way too many times!");
            defer KickEx(playerid);    
            return 1;
        }
        return ShowPlayerLogin(playerid);
    }

    mysql_format(SQL, gString, sizeof gString, "select * from users where id = %d", PlayerInfo[playerid][pSQLID]);
    mysql_pquery(SQL, gString, "OnPlayerLogin", "d", playerid);
    return 1;
}

Nu am folosit acest include pana acum, si m-am gandit ca este o alternativa mai bune fata de WP, si MD5. 
Multumesc pentru timpul acordar!

7 answers to this question

Recommended Posts

  • 0
Posted

Pentru register: 

Dialog:PLAYER_REGISTER(playerid, response, listitem, inputtext[]) {
	if(!response)
		return Kick(playerid);

	if(!(6 <= strlen(inputtext) <= 32)) {
		SendErrorMsg(playerid, "Your password must consist of 6 - 32 characters");
		return ShowPlayerRegister(playerid);
	}

	return bcrypt_hash(playerid, "HashPassword", inputtext, 12);
} 


Pentru login: 

 

Dialog:PLAYER_LOGIN(playerid, response, listitem, inputtext[]) {
	if(!response)
		return Kick(playerid);

	if(!(6 <= strlen(inputtext) <= 32)) {
		SendErrorMsg(playerid, "Your password must consist of 6 - 32 characters");
		return ShowPlayerLogin(playerid);
	}

	return bcrypt_verify(playerid, "PasswordVerify", inputtext, PlayerInfo[playerid][pPassword]);
}

 

  • 0
Posted
7 minutes ago, DonErik said:

Pentru register: 

Dialog:PLAYER_REGISTER(playerid, response, listitem, inputtext[]) {
	if(!response)
		return Kick(playerid);

	if(!(6 <= strlen(inputtext) <= 32)) {
		SendErrorMsg(playerid, "Your password must consist of 6 - 32 characters");
		return ShowPlayerRegister(playerid);
	}

	return bcrypt_hash(playerid, "HashPassword", inputtext, 12);
} 


Pentru login: 

 

Dialog:PLAYER_LOGIN(playerid, response, listitem, inputtext[]) {
	if(!response)
		return Kick(playerid);

	if(!(6 <= strlen(inputtext) <= 32)) {
		SendErrorMsg(playerid, "Your password must consist of 6 - 32 characters");
		return ShowPlayerLogin(playerid);
	}

	return bcrypt_verify(playerid, "PasswordVerify", inputtext, PlayerInfo[playerid][pPassword]);
}

 

pasezi string gol la bcrypt_verify, trebuie sa stochezi parola din db in pPassword inainte sa il pasezi

  • 0
Posted

recomandarea mea este sa ti rescrii putin login/register-ul, cacheuiesti datele player-ului din db in momentu cand s-a conectat si e inregistrat, si asa faci un query doar la connect, eventual sa aplici si un race sanity check pt ca folosesti query-uri threaded, ai aici un exemplu: https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn

  • 0
Posted
8 minutes ago, Sancky said:

recomandarea mea este sa ti rescrii putin login/register-ul, cacheuiesti datele player-ului din db in momentu cand s-a conectat si e inregistrat, si asa faci un query doar la connect, eventual sa aplici si un race sanity check pt ca folosesti query-uri threaded, ai aici un exemplu: https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn

O sa incerc, o sa revin cu un reply.

  • 0
Posted

Revin cu o eroare din consola pe care nu am observat-o 

   Error: Function not registered: 'SSCANF_Init'
   Error: Function not registered: 'SSCANF_IsConnected'
   Error: Function not registered: 'SSCANF_Join'
   Error: Function not registered: 'SSCANF_Leave'
   Error: Function not registered: 'TimeFormat'
   Error: Function not registered: 'bcrypt_verify'
   Error: Function not registered: 'bcrypt_get_hash'
   Error: Function not registered: 'bcrypt_hash'

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.