encrypt password

Posted on 2012-08-20
Last Modified: 2012-08-20
need a way to encrypt a password
and show the password

please write sample code

password is password

echo password
echo encrypted password
Question by:rgb192
    LVL 25

    Accepted Solution

    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 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


    Author Closing Comment


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now