The problem is all of the individual "\n" lines are returning incorrect md5 outputs EXCEPT for the last line (it always returns the correct md5 output)
Here is the code and a sample input/output test at the bottom:
The HTML form
<form action="hash.php" method="post"> <textarea name="hashed" rows=20 cols=41></textarea></br> <input type="submit" value="Generate"> </form>
PHP code used to take individual \n lines and generate the individual line md5 output
$data = $_POST['hashed'] ;
foreach(explode("\n", $data) as $line) {
$hashedData = hash('md5',$line, FALSE);
echo '<strong>'. $hashedData .'</strong></br>';
}
1. You'll notice the first line (apple) generates "md5(apple + something else)" (I'm thinking the actual \n is generated as part of apple hence wrong output)
2. Same thing happens to orange
3. The third line (apple) generates the correct "md5(apple)" output
Sample input:
apple
orange
apple
Sample output:
2f9c032ecf479087117e8d6f7fe1a84f
5b3ef7abd937c92e99d740df67182c1b
1f3870be274f6c49b3e31a0c6728957f
Any suggestions or a possible workaround?
A few things already tried:
- using commas as a separator but it didn't work out too well
- tried reverse-md5'ing the wrong output but no one has yet to rainbow it
- Clean $line from enter \n spaces and %20 spaces, no dice
$clean = str_replace(' ','',$str);
Edited by johnny042, 08 January 2013 - 06:00 PM.











