[php] php MD5 generates only one hashed output

Margaret Iaquinto iaquinto at ozemail.com.au
Tue Nov 23 18:49:44 EST 2010


I used the code below and it generates an MD5 hash and stores the file OK.

Trouble is - each time I enter a different 'userpass' from the form, it 
generates the same hash output.
Why?

I am just a beginner in this, so please don't use esoteric cryptography 
terminology. I need the veggie version.

Maggie

<?php
     /********************
     file: password.php
     called from password.html
     takes password from the form
     and
     encrypts it with MD5
     and
     saves it to  allmysecrets.txt file
     ******************/

     include('header.inc');
     page_header('No one will ever know');

     //gather the password

     $userpass = $_POST['userpass'];


     $storedpass = md5($userpass);
     //open the file allmysecrets.txt
     //use the append mode and then view it b/c I want to
     echo $storedpass;

     $fh = fopen('allmysecrets.txt', 'a');
     //write the encrypted password to the file
     fputs($fh, $storedpass."\r\n");
     //close the file
     fclose($fh);


     include('footer.inc');


?>


More information about the php mailing list