Save Password Before Encrypt In Md5

Hi, i have a user model and when i register a user i encrypt the password in md5(password).

But i need to make a copy of the password before she is encrypted.how can i do this?


protected function afterValidate(){

    parent::afterValidate();

    if($this->password){

      $this->password = $this->encrypt($this->password); 

    }else{

      unset($this->password);

    }

    

  }


  public function encrypt($value){

    return md5($value);

  }	

It’s available in plain text at any time before you hash it. What do you need help with exactly?

i want to save the password without md5() in another table.

for the new users i created user table, but i have another table that use information from user table, and i need users password without md5() in the second table.

i must keep the password in plaint text and in md5 but dont know how.

In this case you can get rid of encryption at all and store plain-text right in $model->password.

Encryption makes sense only if original pwd is not available as text.

Letting users see their passwords shouldnt be done at any time. You should provide a proper password recovery process where the user can set a new password.

Don’t use MD5, either.

Yii has a password helper that will securely hash passwords and is very simple to use.

^-- this! For reference, it’s the CPasswordHelper class.