Skip to content

Instantly share code, notes, and snippets.

@lucashalbert
Created January 29, 2019 17:15
Show Gist options
  • Save lucashalbert/0e72265fca297329d7c39fa0fcf8179b to your computer and use it in GitHub Desktop.
Save lucashalbert/0e72265fca297329d7c39fa0fcf8179b to your computer and use it in GitHub Desktop.
Script to generate a salted sha512 hash
#!/usr/bin/python
import sys;
import getpass;
import crypt;
import uuid;
password = getpass.getpass("New Password: ");
salt = uuid.uuid4().hex [0:8];
#print("Pass:",password);
#print("Salt:",salt);
hash=crypt.crypt(password, "$6$"+salt+"$");
if len(sys.argv) > 1:
username = sys.argv[1]
print(username+": {CRYPT}"+hash);
else:
print("{CRYPT}"+hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment