PDA

View Full Version : SHA256_PassHash confusing me.


VivianKris
21/02/2016, 02:37 PM
GetPlayerName(playerid, playerInfo[playerid][Name], MAX_PLAYER_NAME);
printf("%s\nA", playerInfo[playerid][Name]);
SHA256_PassHash(password, "ex", playerInfo[playerid][Password], MAX_PASSWORD_LENGTH);
printf("%s\nB", playerInfo[playerid][Name]);
new query[512];
mysql_format(mySQL, query, sizeof query, "INSERT INTO `accounts` (`name`, `password`, `cash`, `balance`, `positionx`, `positiony`, `positionz`, `health`) VALUES ('%e', '%s', '500', '1000', '1743.1606','-1864.1298','13.5742', '100.0')", playerInfo[playerid][Name], playerInfo[playerid][Password]);
mysql_tquery(mySQL, query);
printf("%s\n", query);



OUTPUT:


[23:36:56] Kris_Back
A
[23:36:56]
B
[23:36:56] INSERT INTO `accounts` (`name`, `password`, `cash`, `balance`, `positionx`, `positiony`, `positionz`, `health`) VALUES ('', 'D3B60247AFF81DB2C89AD6DC34C93AEE57F6A3D8FC68DD3A9 EFFD1948E88C146', '500', '1000', '1743.1606','-1864.1298','13.5742', '100.0')




Why Name just emptied after SHA256_PassHash???

Vince
21/02/2016, 02:57 PM
Inexplicable changes to variables are usually caused by buffer overflow. Make sure that the password length is at least 65. Not 64. You need the extra character for the null terminator.

VivianKris
21/02/2016, 03:24 PM
thx, fixed.