• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 761
  • Last Modified:

encrypt password

need a way to encrypt a password
and show the password

please write sample code


password is password


echo password
echo encrypted password
0
rgb192
Asked:
rgb192
1 Solution
 
lwadwellCommented:
What do you mean by encrypt and show password?

Safe methods of storing passwords are 'one way' only ...meaning that the supplied password is encrypted and saved as in the encrypted form only.  It is important that strong encryption method is used.  The reason to be one-way only is that is the system was compromised by a hacker - having the encrypted value is not usable by hacker as it cannot be reversed into the plain text password.

refer to http://www.php.net/manual/en/function.crypt.php or details on encryption options in  PHP.


echo '<pre>';

$salt = "xzfbcuasfgbkla tsd7668e32^%*&vjkF^%vmj^&";

$password = "password";
$encpassw = crypt($password,$salt);

echo $password, PHP_EOL;
echo $encpassw, PHP_EOL;

if ( crypt($password,$salt) == $encpassw ) {
    echo "password matches", PHP_EOL;
}

Open in new window

0
 
rgb192Author Commented:
thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now