Search code examples
phppasswordscrypt

how to recover crypted password in php


when a new user registers to my site it uses the crypt() method and then stores it in DB.

I want to make a "i forgot my password" page where a user can get his password by mail.

My question is simply: how do i convert for example ,this: "$2a$13$Ku2hb./9aA71dPo/E015m.WBs6.RsDC/BL8jbz8dMRrmm0jGNIJRO" to "Some user password"?


Solution

  • The crypt() function uses one-way encryption, which means that there is no decrypt() function.

    Basically you have two options:

    1.Implement your own encrypt method which you can decrypt later -not recommended-

    2.Implement a 'reset password' instead