Why does calling encodePassword() with identical salts and passwords produces diffent hashes in Symfony 4?
问题 In UserPassword encoder, public function encodePassword(UserInterface $user, string $plainPassword) { $encoder = $this->encoderFactory->getEncoder($user); return $encoder->encodePassword($plainPassword, $user->getSalt()); } encoder gets the salt from user entity. I set a static variable to the getSalt() in User entity: public function getSalt() { return 'my-static-salt'; } But when I encode: $password = $encoder->encodePassword($user, "my-password"); $password2 = $encoder->encodePassword(