Last active
December 10, 2021 16:46
-
-
Save naftulikay/e7a6ef31fd7d1dce3fcfd252fb435a2f to your computer and use it in GitHub Desktop.
Generate an /etc/shadow compatible passphrase.
This file contains hidden or 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 | |
from crypt import crypt | |
from getpass import getpass | |
from random import SystemRandom ; random = SystemRandom() | |
from string import ascii_lowercase, ascii_uppercase, digits | |
salt_chars = ascii_lowercase + ascii_uppercase + digits | |
# generate a SHA-512 passphrase from user input with a 16 byte random salt | |
passphrase = crypt(getpass(), "$6${}".format(''.join([random.choice(salt_chars) for i in range(16)]))) | |
# print the output | |
print(passphrase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment