1.生成
$password是明文.如:123456
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
2.验证
$password是明文.如:123456,$password_hash是用上面方法生面的password hash,返回true与false
Yii::$app->security->validatePassword($password, $password_hash);