Skip to content

Instantly share code, notes, and snippets.

@immanuelpotter
Created August 3, 2018 12:12
Show Gist options
  • Select an option

  • Save immanuelpotter/b3c4a8aa6056b012fef2c7a74844c3d3 to your computer and use it in GitHub Desktop.

Select an option

Save immanuelpotter/b3c4a8aa6056b012fef2c7a74844c3d3 to your computer and use it in GitHub Desktop.
Read password, hash it, print the hash
#!/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