Last active
September 15, 2023 07:19
-
-
Save chernjie/ceafd6f7bd02cfd77f3738e14c0a9720 to your computer and use it in GitHub Desktop.
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 python | |
# -*- coding: utf-8 -*- | |
from optparse import OptionParser | |
from passlib.hash import sha512_crypt; | |
import getpass; | |
parser = OptionParser(usage="%prog --method=sha-512") | |
parser.add_option( | |
'--method', | |
dest='method', default='', | |
help='chosen method, e.g. sha-512', | |
) | |
(opts, args) = parser.parse_args() | |
def sha512_crypted (password) : | |
print(sha512_crypt.using(rounds=5000).hash(password)) | |
methods = { | |
'sha-512': sha512_crypted, | |
} | |
if __name__ == '__main__': | |
if not opts.method: | |
parser.error("Please provide a method, e.g. sha-512") | |
try: | |
methods[opts.method](getpass.getpass()) | |
except KeyError as ke: | |
parser.error("Method not supported") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment