Hey Com,
Gestern habe ich mühsam mit Blackace das mit dem Hashen gefixxt
Jetzt habe ich weiter gescriptet aber nichts an den Hashzeug da rumgefummelt, da ich davon keine Ahnung habe.
So Problem, Passwort ist falsch:
case DIALOG_REGISTER:
{
new name[64 + sizeof(Servername)], namex[19 + sizeof(Servername)];
format(namex,sizeof(namex),"Registrierung auf %s",Servername);
format(name,sizeof(name),"Bitte wähle ein Passwort\num der %s Community beizutreten:",Servername);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, namex, name, "Anmelden", "Abbrechen"), US_PlayerInfo[playerid][login_count]++;
{
new salt[129], key[129], hashedpw[H_WHIRLPOOL_LEN], _string[450],buffer[256+128];
randomString(salt, 128);
randomString(key, 128);
format(_string, sizeof(_string), "INSERT INTO `Salts` (`Name`, `Salt`, `Key`) VALUES ('%s','%s','%s');", PlayerInfo[playerid][Name], salt, key);
db_free_result(db_query(saltdb, _string));
sql_escape_string(shandle[datarow], inputtext, _string);
strins(_string, salt, 0);
hhash_hmac(H_WHIRLPOOL, _string, key, hashedpw, H_WHIRLPOOL_LEN);
strins(PlayerInfo[playerid][Password], hashedpw, 0);
format(_string, 128, "INSERT INTO `accounts` (`name`, `password`, `whitelist`)");
format(buffer,sizeof(buffer),"VALUES ('%s', '%s', '%b');",PlayerInfo[playerid][Name], PlayerInfo[playerid][Password], PlayerInfo[playerid][Whitelist]);
strcat(_string,buffer);
sql_query(shandle[datarow], _string, QUERY_THREADED, "OnPlayerRegistred", "ri", playerid);
SpawnPlayer(playerid);
}
}
if(!response || US_PlayerInfo[playerid][login_count] == 3) { return _Kick(playerid,""HTML_WHITE"["HTML_ROT"Kick"HTML_WHITE"]: Registrierungsvorgang abgebrochen!"); }
return 1;
}
case DIALOG_LOGIN:
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 128) { return 1; }
else
{
new _string[500], hashedpw[H_WHIRLPOOL_LEN], salt[129], key[129], DBResult:result;
print(PlayerInfo[playerid][Name]);
format(_string, sizeof(_string), "SELECT * FROM `Salts` WHERE `Name`='%s'", PlayerInfo[playerid][Name]);
result = db_query(saltdb, _string);
if(!db_num_rows(result)) { _Kick(playerid, ""HTML_WHITE"["HTML_ROT"SERVER"HTML_WHITE"] Es liegt ein Fehler bei deinem Account vor. Wende dich an einen Administrator! (Fehler-Code: No-Salt!)"); return 1; }
db_get_field_assoc(result, "Key", key, 129);
db_get_field_assoc(result, "Salt", salt, 129);
db_free_result(result);
printf("Key: %s",key), printf("Salt: %s",salt);
strdel(_string,0,sizeof(_string));
sql_escape_string(shandle[datarow], inputtext, _string);
strins(_string, salt, 0);
hhash_hmac(H_WHIRLPOOL, _string, key, hashedpw, H_WHIRLPOOL_LEN);
format(_string, sizeof(_string), "SELECT * FROM `accounts` WHERE `name` = '%s'", PlayerInfo[playerid][Name]);
sql_query(shandle[datarow], _string, QUERY_THREADED | QUERY_CACHED, "LoadPlayer", "ris", playerid,hashedpw);
SetSpawnInfo(playerid,0,0,1958.3783, 1343.1572, 15.3746,0,0,0,0,0,0,0);
TogglePlayerSpectating(playerid, 0);
}
}
}
In der Hashdatenbank ist nur eine Zeile nicht mehr!
Der LoadPlayer noch:
public LoadPlayer(Result:result, playerid, inputtext[])
{
sql_get_field(result, 2, PlayerInfo[playerid][Password]);
if(!strcmp(inputtext,PlayerInfo[playerid][Password],true))
{
PlayerInfo[playerid][Admin] = sql_get_field_int(result, 4);
PlayerInfo[playerid][Geld] = sql_get_field_int(result, 5);
PlayerInfo[playerid][Handynummer] = sql_get_field_int(result,6);
SpawnPlayer(playerid);
GivePlayerMoney(playerid,PlayerInfo[playerid][Geld]);
US_PlayerInfo[playerid][loggedin] = true;
printf("* %s geladen. *", PlayerInfo[playerid][Name]);
}
else _Kick(playerid,"Error: Passwort falsch!");
sql_free_result(result);
return 1;
}
Danke euch