Note that there are some explanatory texts on larger screens.

plurals
  1. POMigrating from FOSUserBundle to Django
    primarykey
    data
    text
    <p>I'm in the process of migrate a php site with FOSUserBundle to a Django user model.</p> <p>The content of <code>app/config/security.yml</code>:</p> <pre><code>security: encoders: FOS\UserBundle\Model\UserInterface: sha512 </code></pre> <p>Values of password/salt from a user test at the PHP site:</p> <ul> <li>password: <code>3EBoIIMrD73n2y+4hMUpCq2lmJ8tHStrBweonQClP+/Jhmaw7ipLbamQJQfB87Acg45sBH3HlgnpKI+QZN7m/Q==</code></li> <li>salt: <code>2n4fxtazv1us0csgg8s880ck4skcskg</code></li> <li>The password used is <code>amdpower</code></li> </ul> <p>I've tried to generate the same hash with this code:</p> <pre><code>raw_password = 'amdpower' salt = '2n4fxtazv1us0csgg8s880ck4skcskg' salted = '%s{%s}' % (raw_password, salt) digest = hashlib.sha512(salted).digest() for i in range(5000): digest = hashlib.sha512(digest).digest() print base64.b64encode(digest) &gt;&gt;&gt; wqgbbFZ/IPvwZktbmYz7inffofmT5HbRNf04BQ+w33Jgman8uVYbjWyiKzfp5EIFX2wqYGOb7hRzi5BdZlzDKw== </code></pre> <p>What's wrong with the hashing code I've tried? How can I generate the same hash?</p> <p>Update:</p> <p>The PHP funcs are:</p> <ul> <li><p>FOSUserBundle: <a href="https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/UserManager.php#L180" rel="nofollow">https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/UserManager.php#L180</a></p></li> <li><p>Symfony: <a href="https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Security/Core/Encoder" rel="nofollow">https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Security/Core/Encoder</a></p></li> </ul> <p>Solved:</p> <pre><code>raw_password = 'amdpower' salt = '2n4fxtazv1us0csgg8s880ck4skcskg' salted = '%s{%s}' % (raw_password, salt) digest = hashlib.sha512(salted).digest() for i in range(4999): digest = hashlib.sha512('%s%s' % (digest, salted)).digest() print base64.b64encode(digest) &gt;&gt;&gt; 3EBoIIMrD73n2y+4hMUpCq2lmJ8tHStrBweonQClP+/Jhmaw7ipLbamQJQfB87Acg45sBH3HlgnpKI+QZN7m/Q== </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload