I am trying to encrypt a password using the PHP crypt function. In yii, it's recommended to use CPasswordHelper. When I call CPasswordHelper::hashPassword($password), it says Class 'common\models\CPasswordHelper' not found.
Please help?
To generate hashed password in Yii 2 use security component.
security
You can generate password hash with:
$hash = \Yii::$app->getSecurity()->generatePasswordHash($rawUserPassword);
To validate this password later on you can check:
if (\Yii::$app->getSecurity()->validatePassword($rawUserPassword, $hash) {}
Read more about this in the Guide.
To generate hashed password in Yii 2 use
security
component.You can generate password hash with:
To validate this password later on you can check:
Read more about this in the Guide.