Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP Md4 Hasher?


ghost's Avatar
0 0

Well, my MD5 and SHA1 hasher work but I can't seem to find a way to make it work for MD4, or SHA2. I tried doing this : markup<?php $encrypted = md4("$unencrypted"); ?> and markup<?php $encrypted = sha2("$unencrypted"); ?> but that just doesn't seem to work, any idea guys?


ghost's Avatar
0 0

A quick google search uncovered this:

http://us2.php.net/hash

where they seem to use this:

markup$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));

To make an MD4 hash. What's wrong with MD5 and SHA1 though?


ghost's Avatar
0 0

Nothing is wrong with them, i'm just saying that I got those to work, and not the sha2 or md4.

How would I add this to a form? A lot different so it's hard…Any idea?


ghost's Avatar
0 0

hefty wrote: Nothing is wrong with them, i'm just saying that I got those to work, and not the sha2 or md4.

I was unaware really that PHP even had functions built in to handle MD4 and SHA2.


ghost's Avatar
0 0

Yah, well any idea how to get this into a form? markup$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));


ghost's Avatar
0 0

hefty wrote: Yah, well any idea how to get this into a form? markup$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));

Lol what do you mean? You could make it into a function like this:

Function MD4($input) {
$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));
}

And use it regularly (md4($hash);) like you would MD5. Of course you should also sanitize your strings too, I didn't include anything from a security perspective though.


ghost's Avatar
0 0

I'm trying to make it work like this:

    Text to Hash: <input type="text" name="mhash"><p/>
    <input type="submit" name="Submit" value="Submit">
</form><p />
<?php 
$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input))
?>
Your origional text: <?php echo "$unencrypted"; ?><p />
Your MD4 hashed text: <?php echo "$MD4Hash"; ?><p />```

EDIT: Just can't seem to make it work with our input.

ghost's Avatar
0 0

This should work though untested so:

<?php
Function MD4($input) {
$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));
}
echo <<<THIS
<form name="hasher" method="post" action="">
Text to Hash: <input type="text" name="mhash"><p/>
<input type="submit" name="Submit" value="Submit">
</form><p />
THIS;
if ($_POST['mhash'])
{
$info=md4($input);
echo($info);
}
else
die();
?>

ghost's Avatar
0 0

Sadly it doesn't.


ghost's Avatar
0 0

hefty wrote: Sadly it doesn't.

You need the mhash plugin, and yeah I know it still doesn't work. I'll do some troubleshooting I'm kinda interested now :p


ghost's Avatar
0 0

Haha, yah working on a site with all these tools. I'll try to make it work, if you get it to work reply back =)


ghost's Avatar
0 0

Too bad my server only has 4


ghost's Avatar
0 0

^oh lol :o damn I think I had this shit figured out too.

only_samurai wrote: in php 5.2+ you can use hash

hash("md5","password")

http://www.php.net/manual/en/function.hash.php

He's right lol and it works with MD4. Gj I was unaware of this function B)


ghost's Avatar
0 0
<?php
Function MD4($input) {
return $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));
}
echo <<<THIS
<form name="hasher" method="post" action="">
Text to Hash: <input type="text" name="mhash"><p/>
<input type="submit" name="Submit" value="Submit">
</form><p />
THIS;
if (isset($_POST['mhash']))
{
$newhash = md4($_POST['mhash']);
echo $newhash;
die();
}
else
die();
?>

Here you go, a working MD4 hasher for your version. Cheers m8 B) BUT YOU NEED THE MHASH MODULE INSTALLED AND ENABLED. ;)


ghost's Avatar
0 0

hefty wrote: Works, but for some reason it makes my bottom image on my page dieapear when you click submit. http://elitecs.info/tools/md4.php

Nah, it doesn't for me but that's not the problem. My problem is no matter what you hash with it it returns the same hash. I have no fucking clue why sorry mate I guess I can't really help you here :(


ghost's Avatar
0 0

Yah, who knows.


ghost's Avatar
0 0

I'm still not giving up yet :@:) hang on I'll figure it out.


ghost's Avatar
0 0

K lol I give, but I have it pretty much nailed to one area:

<?php
Function md4(&$input) {
$input=bin2hex(mhash(MHASH_MD4,$Input));
}
echo <<<THIS
<form name="hasher" method="post" action="">
Text to Hash: <input type="text" name="mhash"><p/>
<input type="submit" name="Submit" value="Submit">
</form><p />
THIS;
if (isset($_POST['mhash']))
{
md4($_POST['mhash']);
echo $_POST['mhash'];
}
else
die();
?>

It HAS to be somewhere in the MD4 function where it's hashing a string in MD4 and it's not $input and outputting that string, not your input. You could try and crack the md4 hash it outputs to try and figure out what the function is hashing and fix it that way though.


ghost's Avatar
0 0

AHA got it :happy:

<?php
Function MD4(&$input) {
$input=bin2hex(mhash(MHASH_MD4,$input));
}
echo <<<THIS
<form name="hasher" method="post" action="">
Text to Hash: <input type="text" name="mhash"><p/>
<input type="submit" name="Submit" value="Submit">
</form><p />
THIS;
if (isset($_POST['mhash']))
{
md4($_POST['mhash']);
echo $_POST['mhash'];
}
else
die();
?>

Capital letters in the variables inside the function fucked it up. Here is an MD4 hasher, working.


ghost's Avatar
0 0

Yay lol! Thanks so much.