Fosuserbundle uses sha512 Encryption by default. If you want to implement your own encryption method, you must inherit symfony \ component \ SECURITY \ core \ encoder \ basepasswordencoder <? Phpnamespace Mc \ adminbundle \ SECURITY \ encoder; Use symfony \ component \ SECURITY \ core \ encoder \ basepasswordencoder; Use symfony \ component \ securitycore \ exception \ badcredentialsexception; class joomlapasswordencoder extends basepasswordencoder {private $ cost; public function _ construct ($ cost) {$ cost = intval ($ cost ); if ($ cost <4 | $ cost> 31) {Throw new \ invalidargumentexception ('cost too long, it must be in the range of 4-31 ');} $ this-> Cost = sprintf ('% 02d', $ cost);} public function encodepassword ($ raw, $ salt = NULL) {if ($ this-> ispasswordtoolong ($ raw) {Throw new badcredentialsexception ('invalid password. ');} return MD5 (MD5 ($ raw ). $ salt);} public function ispasswordvalid ($ encoded, $ raw, $ salt = NULL) {if ($ this-> ispasswordtoolong ($ raw) {return false ;} return MD5 (MD5 ($ raw ). $ salt) ===$ encoded;} and then write the resources/config/services of the Service under the bundle. yml (or XML) adds a service: mc_user.security.core.encoder: Class: Mc \ adminbundle \ SECURITY \ encoder \ joomlapasswordencoder arguments: [6] Or dependencyinjection/configuration. add parameters in PHP: $ rootnode-> Children ()-> scalarnode ('cost')-> defaultvalue (6)-> end (); finally, in APP/config/security. in yml, set your own encryption method. Here, the user component is fosuserbundle: Security: encoders: symfony \ component \ SECURITY \ core \ User: plaintext Fos \ userbundle \ model \ userinterface: ID: mc_user.security.core.encoder the ID here is the service name mc_user.encoderdone
Symfony2 usersecurityencoder implements its own authentication method