I would like to store a hashed password in the database but by that time I haven’t load Yii yet (due to my custom application installer). I want to know the equivalent of
CPasswordHelper::hashPassword($password);
in PHP. SO far I have tried with the PHP
password_hash()
function like this:
password_hash(filter_input(INPUT_POST, 'portal_password', FILTER_SANITIZE_STRING), PASSWORD_BCRYPT, array("cost" => 13));
The result comes out like:
$2y$13$nhWAdiJeznsOqHph0yZaAOINqg14pGppOUqqyisaXsQuBtRKD076W
but when I tried to login with my original password, it failed. I notice that often the result of CPasswordHelper::hashPassword has
$2a$13
but mine has
$2y$13
prefix. Anyone could help? Thanks!