简体   繁体   中英

PHP Password different all time

I am using following method for saving password in database during signup.

'reg_password'=>password_hash($this->input->post('password'), PASSWORD_DEFAULT, ['cost' => 15]),

I am using following method for during login.

'Password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT, ['cost' => 15])

Everytime I am getting different hashed password How can I resolve this? and sorry for my weak English.

password_hash() helps to convert the user's input password for the first time at sign_up and will then return this information (hash + salt) in a single string suitable for storing with the user's record in the database. It can not be used to check whether the user input matches with the already hashed password in the database. For that you need to use the password_verify() method to check if the password exists.For Example

'Password' => password_verify($this->input->post('password'), $stored_password);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM