PHP Md4 Hasher?
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?
A quick google search uncovered this:
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?
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.
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.
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();
?>
^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)
<?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. ;)
Works, but for some reason it makes my bottom image on my page dieapear when you click submit. http://elitecs.info/tools/md4.php
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 :(
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.
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.