We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to decrypt hash security

Save crypt hash security:

    $usuario = new User();
    $usuario->password = $this->security->hash($this->request->getPost("pass"));
    if (!$usuario->save()) {
        foreach ($usuario->getMessages() as $message) {
        $this->flash->error($message);
        }
        $this->dispatcher->forward([
            'controller' => "usuario",
            'action' => 'new'
        ]);

        return;
    }

now, How to decrypt hash security to send my form:

        $usuario = User::findFirstByid($iduser);
        $this->tag->setDefault("pass", $this->encryption->decrypt($usuario->password));

I having a error: Notice: Access to undefined property encryption in ...

You can't decrypt hashes. They are one only way by definition. Also there is on such service as encryption.

But if I want to edit my password? I get so in my form:

<input type="text" id="fieldpass" name="pass" value="c0bd96dc7ea4ec56741a4e07f6ce98012814d853" class="form-control" >

edited Feb '17

You can't edit it in hash form, you need to set new one. Also you should use element password not text.

I do not know how I would do that on my form. You could give me an idea how to do it profavor. I would thank you.



145.0k
Accepted
answer

I updated latest answer, I'm not using phalcon forms but perhaps you need password element, not text.

I'm new to phalcon, I'm not understanding much, but thanks for responding.

In any Password reset system, you SHOULD ask the previous password, compare that to DB if the right one was supplied, then compare the new password with a confimation and then set the password to new hash value. Most systems have 3 fields: Current, New, Confirm New.