Showing posts with label yii2 password validation. Show all posts
Showing posts with label yii2 password validation. Show all posts

Monday, April 30, 2018

yii2 decrypt password

Password Decryption in Yii2

Yii2 have inbuilt functions for encrypt/decrypt data using secret key. Yii2 getSecurity() method return the pseudo random data which is useful for encrypt/decrypt your hash data. The given example describe the validate password and set password methods:

public $key = 'SECRET KEY';
public function setPassword($pwd)
{
    $this->password_hash = Yii::$app->getSecurity()->encryptByPassword($pwd, $this->key);
}
public function validatePassword($pwd)
{
    $decryptPassword = Yii::$app->getSecurity()->decryptByPassword($this->password_hash, $this->key);
    return $decryptPassword === $pwd;
}

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search