How to :Encrypt password in PHP

In the above figure , the password is not encrypted . So it can be easily hacked .

To prevent from hacks ,I am going to encrypt the password .

Syntax for MD5 :

$password=”12345″;

md5($password);

When  we encrypt the password “12345 ”

it will give 827ccb0eea8a706c4c34a16891f84e7b

Now when we apply reverse md5 to above result , we will get the original password “12345”.

For Example ,

Output:

6 Responses to “How to :Encrypt password in PHP”
  1. kannan

    Hi gautham, nice and easy method though. But one thing you can get md5 value of a string then save it in ur database, and when authenticating you cannot reverse md5 it to get the original string but again md5 the given password and check both this value and the md5 value in the database. Because as far as I know md5 is a assymentric algorithum means its a 1-way encryption algorithum and the reverse is not always possible. (there are md5 hash database which can be used to find some of the most commonly used passwords, its kind of a dictionary attack, one most famous site for this is http://gdataonline.com/)

    • N.S Gautham Raj

      Thanks Kannan . Your Favourite Algorithm??

      • Kannan

        It was, but nowadays all the algo are getting cracked 🙁 . And the pic at bottom looks cool. You n ganesh rocks.

  2. Tom

    md5 is not secure, in part thanks to rainbow tables, which makes for easy lookup via Google.

    Please do not use it to encrypt passwords, and don’t encourage your readers to do so either. It’s about as secure as rot13.
    See, e.g.
    http://stackoverflow.com/questions/5225249/secure-way-to-encrypt-password
    http://stackoverflow.com/questions/1289061/best-way-to-use-php-to-encrypt-and-decrypt

  3. prabhu

    How To descrypt password

  4. Amit

    kannan ,who said that in asymmetric algo..reverse is possible???????????? please learn more……..

Leave a Reply

*