UserIdentity and Password encryption


(Omzy83) #1

How can I enable password encryption in the database for use with UserIdentity?


(O Rijkers) #2

when the user enters a new password, before storing it encrypt it (like $password=md5($password);).

when logging in, again first encrypt the entered password and then compare it with the value in the database.


(Omzy83) #3

hmmm is there no built-in functioniality in Yii/UserIdentity component that will automate this process?

I need to also add a salt to the password.

EDIT: RESOLVED


(Contact) #4

stronger hash function:




	static function passwordHash($pass)

	{

		return hash('sha256', Yii::app()->params['hashSalt'].$pass);

	}	



and add a ‘hashSalt’ param to your main.php config file