Skip to content

Instantly share code, notes, and snippets.

@c-neto
Last active October 18, 2023 17:39
Show Gist options
  • Save c-neto/a1ddca4e148aa36651e9ec63488668fa to your computer and use it in GitHub Desktop.
Save c-neto/a1ddca4e148aa36651e9ec63488668fa to your computer and use it in GitHub Desktop.
Generate hash SHA-512 with salt
# requires: pip install passlib
from passlib import hash
x = hash.sha512_crypt.hash("carlos", salt="neto", rounds=5000)
y = hash.sha512_crypt.hash("carlos", salt="xxx", rounds=5000)
print(hash.sha512_crypt.verify("carlos", x))
# >>> true
print(hash.sha512_crypt.verify("carlos", y))
# >>> true
print(hash.sha512_crypt.verify("liks", x))
# >>> false
print(hash.sha512_crypt.verify("liks", y))
# >>> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment