I did a simple command in symfony to take a value from the console and encode it:
$io = new SymfonyStyle($input, $output);
$email = $input->getArgument('email');
/** @var User $user */
$user = $this->em->getRepository(User::class)->findOneBy([
'email' => $email
]);
if (empty($user)) {
$io->error("User with email '$email' not found");
return 0;
}
$password = $io->askHidden('Password: ');
$hash = $this->encoder->encodePassword($user, $password);
$io->text("Generated hash: $hash");
Security config fragment:
security:
encoders:
App\Entity\User:
algorithm: bcrypt
providers:
app_user_provider:
entity:
class: App\Entity\User
property: email
Is it okay that each call for the same entered value generates a different value? How is it possible to verify when accessing that the passwords are the same if for equal values it generates a different encoding?