Last active
November 22, 2023 23:34
-
-
Save gronke/33b2ce85001ee706a55f6721f226c3e7 to your computer and use it in GitHub Desktop.
Generate SHA512-CRYPT with Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import secrets | |
import passlib.hash | |
import sys | |
def generateHash(password, salt_len=10, iterations=65000): | |
result = passlib.hash.sha512_crypt(salt=secrets.token_hex(salt_len), rounds=iterations).hash(password) | |
return '{SHA512-CRYPT}' + result | |
user_input = sys.argv[1] | |
print(generateHash(user_input)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, thank you for a good example. But you should use sha512_crypt.using() function if you want to change iterations number