MyBB password hash - 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)
+--- Thread: MyBB password hash (
/showthread.php?tid=470941)
MyBB password hash -
kristo - 20.10.2013
I'm trying to make a MyBB hash generator but it keeps giving me wrong hashes and cancers.
My function:
pawn Код:
stock HashMyBBPassword(string[], salt[])
{
new string2[48];
format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), string);
string2 = MD5_Hash(string2);
return string2;
}
Original function (PHP):
PHP код:
function salt_password($password, $salt)
{
return md5(md5($salt).$password);
}
What am I doing wrong?
Re: MyBB password hash -
kristo - 20.10.2013
Still waiting for help.
Re: MyBB password hash -
AndreT - 20.10.2013
MyBB code:
PHP код:
function generate_salt()
{
return random_str(8);
}
function salt_password($password, $salt)
{
return md5(md5($salt).$password);
}
$pass = $mybb->input['password'];
$md5pass = md5($pass);
$salt = generate_salt();
$salted_pass = salt_password($md5pass, $salt);
As you can see, $md5pass, which contains a MD5 hash, gets passed to the function salt_password.
So there's your mistake.
Re: MyBB password hash -
Smally - 20.10.2013
http://community.mybb.com/thread-124386.html
Re: MyBB password hash -
kristo - 20.10.2013
Quote:
Originally Posted by AndreT
MyBB code:
PHP код:
function generate_salt()
{
return random_str(8);
}
function salt_password($password, $salt)
{
return md5(md5($salt).$password);
}
$pass = $mybb->input['password'];
$md5pass = md5($pass);
$salt = generate_salt();
$salted_pass = salt_password($md5pass, $salt);
As you can see, $md5pass, which contains a MD5 hash, gets passed to the function salt_password.
So there's your mistake.
|
Oh, didn't see that part. I'll test it, thanks.
Also thanks to Smally.
Re: MyBB password hash -
kristo - 20.10.2013
Idk... I'm still getting wrong hashes.
pawn Код:
stock HashMyBBPassword(string[], salt[])
{
new string2[96];
format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
string2 = MD5_Hash(string2);
return string2;
}
Re: MyBB password hash -
kristo - 20.10.2013
Bump.
Re: MyBB password hash -
rickisme - 20.10.2013
problem is MD5_Hash always return a upper string (:
check this code to see what's different:
pawn Код:
// old hash
stock HashMyBBPassword(string[], salt[])
{
new string2[96];
format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
string2 = MD5_Hash(string2);
return string2;
}
//new hash
stock HashMyBBPassword2(string[], salt[])
{
new string2[96];
format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
for(new i=0; i < sizeof(string2); i++)
{
string2[i] = tolower(string2[i]);
}
string2 = MD5_Hash(string2);
return string2;
}
public OnGameModeInit()
{
new string[128];
format(string, sizeof(string), "%s", HashMyBBPassword("password", "salt"));
printf("old hash : %s", string);
format(string, sizeof(string), "%s", HashMyBBPassword2("password", "salt"));
printf("new hash : %s", string);
return 1;
}
Re: MyBB password hash -
kristo - 20.10.2013
YEAH! Working, repping you asap. I didn't think about case.