I had exactly the same problem, and I had to dig into the code to find out why.
You do not need to create a custom encoder.
By default, the MessageDigestPasswordEncoder encoder ( Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder ) in Symfony 2.5 — and possibly all releases of Symfony 2 — calculates the MD5 hash of the raw password using / without salt, as expected, MD5 hashes several times (5,000 times, by default, in Symfony 2.5). To make things a little more exciting, the encoder will also encode the base64 hash code by default. Both of these features were causing problems for me.
You can fix the problem by disabling re-hashing and / or disabling base64 encoding in security.yml this way:
security: encoders: Namespace\Of\Your\User: algorithm: md5 encode_as_base64: false iterations: 0
Hope this saves you some time.
Dan b source share