FOSUserBundle Encryption Password

I have a symfony project using FOSUSerBundle to manage users. Now I need to access the database via Simple Rest Webservice, Encryption during registration: Sha512, How can I get the same hash result as FOS I tried:

hash('sha512',($salt.$password)); 

and

 hash('sha512',($password.$salt)); 

But it does not work! Any suggestions?

+6
source share
1 answer

According to the class of things that encode fOSUserBundle fos passwords, you can understand how Symfony did its encryption

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php

So you get something like:

 $password = 'toto'; $salt = '1234'; $salted = $password.'{'.$salt.'}'; $digest = hash('sha512', $salted, true); for ($i=1; $i<5000; $i++) { $digest = hash('sha512', $digest.$salted, true); } $encodedPassword = base64_encode($digest); 
+12
source

Source: https://habr.com/ru/post/977609/


All Articles