Created
July 10, 2018 15:13
-
-
Save andrewslotin/9bb1a55b45c4028d501b2db67c535ab1 to your computer and use it in GitHub Desktop.
/etc/shadow compatible password encryption using SHA-512 hash with salt
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 crypt | |
from getpass import getpass | |
try: | |
from passlib.hash import sha512_crypt | |
except ImportError: | |
from sys import stderr | |
stderr.write("please run 'pip3 install passlib' to make sure you have passlib installed\n") | |
exit(1) | |
password = getpass() | |
while getpass("Re-type password: ") != password: | |
print("\nPasswords don't match, please try again") | |
password = getpass() | |
salt = crypt.mksalt(crypt.METHOD_SHA512).split("$")[-1] | |
print(sha512_crypt.hash(password, salt=salt, rounds=5000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment