Password encrypting problem

I want to change password using this function in my module if user want to change their password

public $hash=‘md5’;

public function encrypting($string="") {

	$hash = Yii::app()->User->hash;

	if ($hash=="md5")

		return md5($string);

	if ($hash=="sha1")

		return sha1($string);


		return hash($hash,$string);


problem is when I click submit then I got this error



CWebUser does not have a method named "encrypting".

Source File

have any idea?

CWebUser really doesn’t have a method named “encrypting” :)

I guess it’s a method of your module (probably UserModule), so you should call it like that:

// In module's controllers:

$hash = $this->module->encrypting($string);

// From other controllers (probably you won't need this)

$hash = Yii::app()->getModule('User')->encrypting($string);

I got this error

Fatal error: Call to a member function encrypting() on a non-object in controllers/SiteController.php on line 176

176 line is

$find->password = Yii::app()->getModule(‘User’)->encrypting($string);

You do a getModule(‘User’) --> User is written with a Capital U

Should it be getModule(‘user’)? --> User is written with a lowercase u