Last active
September 25, 2022 06:19
-
-
Save ryot4/871813a4af8f84f618496ff6b3993336 to your computer and use it in GitHub Desktop.
Hash passwords
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 | |
import argparse | |
import crypt | |
from crypt import METHOD_SHA256, METHOD_SHA512, METHOD_BLOWFISH, crypt, mksalt | |
from getpass import getpass | |
parser = argparse.ArgumentParser(description='Hash passwords') | |
parser.add_argument('-5', | |
action='store_const', | |
const=METHOD_SHA256, | |
dest='method', | |
help='Use SHA-256 algorithm') | |
parser.add_argument('-6', | |
action='store_const', | |
const=METHOD_SHA512, | |
dest='method', | |
help='Use SHA-512 algorithm') | |
parser.add_argument('-bcrypt', | |
action='store_const', | |
const=METHOD_BLOWFISH, | |
dest='method', | |
help='Use Blowfish algorithm') | |
args = parser.parse_args(namespace=argparse.Namespace(method=METHOD_SHA256)) | |
print(crypt(getpass(), mksalt(args.method))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment