简体   繁体   中英

PHP: 'salt' option to password_hash is deprecated

I'm using password hashing for a registration. I need to create a Salt manually and following is the code I have used:

$options = [
    'cost' => 11,
    'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)
];
$password = password_hash(
    $this->input->post("confirm_password"),
    PASSWORD_BCRYPT,
    $options
);

When I run this code it gives me an error saying:

password_hash(): Use of the 'salt' option to password_hash is deprecated"

Any solution for this?

Yes, there's a solution - don't use the 'salt' option.

You don't need to salt manually, PHP does that automatically for you.

It's not an option to add salt, but to replace the would-be-generated one, and under no circumstances would you be able to provide a better salt - that's why it's deprecated.

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