Created
August 3, 2018 12:12
-
-
Save immanuelpotter/b3c4a8aa6056b012fef2c7a74844c3d3 to your computer and use it in GitHub Desktop.
Read password, hash it, print the hash
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 crypt,getpass | |
| def prompt(): | |
| global pass1,pass2 | |
| pass1 = getpass.getpass("Enter your first password.\n") | |
| pass2 = getpass.getpass("Enter your password again.\n") | |
| return pass1,pass2 | |
| def make_hash(password): | |
| crypted = (crypt.crypt(password,crypt.mksalt(crypt.METHOD_SHA512))) | |
| return crypted | |
| # Different crypto methods: https://docs.python.org/3/library/crypt.html#hashing-methods | |
| def main(): | |
| prompt() | |
| if pass1 == pass2: | |
| print(make_hash(pass1)) | |
| else: | |
| print("Passwords dont match. Try again, or Ctrl + C to quit") | |
| main() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment