How to get decoded password?

Hello there! Again help please.
Im doin users can change password.
Theres problem and its;
when i call

$site->user(get(‘password’));

Its gives me encrypted password…
How can i get decoded password ?
Thanks,good works!

You can’t decode the hash, it’s a one way hash function.

How can i compare real and post password mean (old password post) ?

What are you trying to do? Build a login form?

Im trying to make a Password Change form.
Its takes;

Old Password
New Password
New Password Again

1 Like

You can use the match() method of the password class.

/**
   * Checks if a password matches the encrypted hash
   * 
   * @param string $plaintext
   * @param string $hash
   * @return boolean
   */
  public static function match($plaintext, $hash) {
    return crypt($plaintext, $hash) === $hash;
  }  

Wow which thing should i put?
My variables are

$OldPassword
$NewPassword
$NewPasswordre

How can i compare user password with $OldPassword ?

Something like:

$oldPassword = 'my_secret_pw';
$user = $site->user('user_name');
$hash = $user->data()['password'];
if(password::match($oldPassword, $hash)) {
 echo "The password is correct";
}
1 Like