Jump to content

[SOLVED] String troubles


slpctrl

Recommended Posts

I can't figure out why this isn't outputting my data correctly. (using the mhash module)

 

<?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 (isset($_POST['mhash']))
{
$info=md4($input);
echo($info);
}
else
die();
?>

Link to comment
https://forums.phpfreaks.com/topic/103204-solved-string-troubles/
Share on other sites

One obvious problem I found is:

 

<?php
Function MD4($input) {
$MD4Hash=bin2hex(mhash(MHASH_MD4,$Input));
return $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']);
}
else
die();
?>

 

The correct variable to md4 is $_POST['mhash']; and not $input (I used that variable but changed it). So, here's where I'm at and no luck. :(

<?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();
?>

 

Do you want it to return it, or do you want it to actually change the value of what you pass to it?  Since you aren't storing it in a variable in the example script, I'll assume you want it to actually change $_POST['mhash'].

 

Try that code.

<?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();
?>

 

Do you want it to return it, or do you want it to actually change the value of what you pass to it?  Since you aren't storing it in a variable in the example script, I'll assume you want it to actually change $_POST['mhash'].

 

Try that code.

 

I got it kinda...it's doing the same thing as my code currently:

 

<?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;
}
else
die();
?>

 

It returns the same hash for every string I input :\

If anyone is interested here is working code:

 

<?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 was the cap in $Input in the MD4 function that threw it off  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.