To work with users connected FOSUserBundle. When creating a user or checking a password, the bandl uses one of the following algorithms: bcrypt, sha512, etc. How do I specify my own hash check algorithm? The table with users comes from a third-party project. You need to make authorization using the same login and password as in the table, but the password hash in this table is obtained in this way base64_encode (md5 ('password', true) and a certain set of characters is added to the beginning of the hash.

    1 answer 1

    I myself will answer :)

    Need to override encodePassword

    <?php namespace UserBundle\Service; use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; class AmsPasswordEncoder implements PasswordEncoderInterface { public function encodePassword($raw, $salt) { $hash = "{MD5}" . base64_encode(md5($raw, true)); return $hash; } public function isPasswordValid($encoded, $raw, $salt) { // TODO: Implement isPasswordValid() method. return $encoded === $this->encodePassword($raw, $salt); } 

    }