I need to compare the password entered by the user if it is valid or not. How do i get the sha512 encryption. I am also using FOSUserBundle in my project.
In your controller you can do (assuming that you set sha512 as encoding algorithm in app/config/security.yml
)
$userName = 'username';
$password = "pass";
$userManager = $this->get('fos_user.user_manager');
$user = $userManager->loadUserByUsername($userName);
$encoder = $this->get('security.encoder_factory')->getEncoder($user);
$encodedPass = $encoder->encodePassword($password, $user->getSalt());
echo $user->getPassword() === $encodedPass;