Skip to content

Instantly share code, notes, and snippets.

@themonti
Last active February 7, 2019 16:52
Show Gist options
  • Save themonti/789edcd4e9b41e2db023b74fc800abd0 to your computer and use it in GitHub Desktop.
Save themonti/789edcd4e9b41e2db023b74fc800abd0 to your computer and use it in GitHub Desktop.
check symfony2 password with python
import hashlib,base64
def checkPass(password,salt):
salted=(password+'{'+salt+'}').encode('utf-8')
if not salt:
salted=password.encode('utf-8')
m=hashlib.sha512()
m.update(salted)
digest=m.digest()
for i in range(4999):
m=hashlib.sha512()
m.update(digest+salted)
digest=m.digest()
return base64.b64encode(digest).decode('utf-8')
print (checkPass('password123','salt1223'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment