I have a form, that I created via Symfony formBuilder
Like this I see the encrypted password in my field:
$formBuilder->add('password', TextType::class, array('attr' => array('class' => 'form-control')));
But actually I need to use a plainPassword field (to encode the password later):
$formBuilder->add('plainPassword', TextType::class, array('attr' => array('class' => 'form-control')));
But this field is empty. I would like to see the decrypted password from the database. How can I realize this?
Ideally your password is hashed in a way, that you can't easily retrieve the actual password from the stored string. Instead you hash the user input with the same options and compare if both hashes match. You are trying to circumvent a security mechanism by displaying the plain password.
Preferably you would not show the user the original password. Either they know it or they should request a new password which you send them via mail or even better give them a token with which they can enter a new password without specifying the existing one.
If for some reason you have to dismiss this advice and actually display the plain password (again, this is highly insecure) then you have to store it in a way where you can read it either alongside the hashed password or instead of hashing it. You could also use encryption instead of hashing, e.g. by using openssl_encrypt
for storing the password and then the decrypt-counterpart when displaying it.