Problem with password encryption (PHP)

2

I'm doing a Pet Shop system and the problem is this: the customer does the registration, and the password is encrypted to the bank, but at the time of login it gives error. Example: the user is Marcos and his password is 123. At the time of login, if I put the password "123" does not enter, only enters if the encrypted code is placed.

    
asked by anonymous 21.10.2015 / 02:28

1 answer

1
  • Regardless of the encryption used for records in the database.
  • On the login screen retrieve the entered password and apply the same encryption of the password in the bank.
  • Compare the two strings and, if they are the same, log in.
  • Code

    $senhaBanco = md5('123');
    
    $senhaDigitada = '123';
    
    echo md5($senhaDigitada) === $senhaBanco // true
    
        
    21.10.2015 / 02:48