I used the password function to store a encrypted password in my database and now i want to be able to open that encryption for and admin section.

originally used this built in encryption for mySQL database
password('my_password');

here is a shorten clip of my code so you can see what i mean.
I am trying to pull the unencrypted password out

//....
$query = "SELECT * FROM my_table WHERE id = '$id'";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_array($result))
{
    echo "$row['pass'];
}

can i pull the this out somehow so my admin page can view the entered password or is this a permanent fix.

thanks for your time.

    After checking MySQL.com and a few other references, it looks like the password() function is a one-way hash. So, it can't be reversed.

      The password function you are using is used in the mysql authentication table. If I remember right it notes in the manual not to use it for your own apps.

      The password() function is a one way encryption, meaning you'll be unable to display the password in plaintext again unless someone enters the password and you use the unencrypted login password. If you intend to go that route (which isn't exactly secure) use MD5() or SHA() encryption.

      Your other option is to use the encrypt() function which will allow you to convert both directions. The PHP equivalent is crypt().

      It has two arguments, the password and a keystring. You'll need the keystring to be the same at all times.

      Here is an example for php:

      http://127.0.0.1/?pass=hrm

      <?
      $crypted = crypt($pass,"test");
      $decrypted = crypt($crypted,"test");
      
      print "Crypted pass: $crypted";
      print "Decrypted pass: $decrypted";
      ?>
      

      Hope this helps!

      -Kaz

        Thanks for you responses.

        Hey Kazer
        The link you posted didn't seem to work very well.

        Thanks

          Write a Reply...