pass.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. import random
  3. import pyperclip
  4. import re
  5. import sys
  6. import argparse
  7. password_file = "drowsapp.org"
  8. def parse_arguments():
  9. parser = argparse.ArgumentParser(description='pass.py')
  10. parser.add_argument('-f', '--find', type=str, metavar='NAME', help='Find password credentials')
  11. parser.add_argument('-n', '--new', action="store_true", default=False, help='Create a new account credentials')
  12. args = parser.parse_args()
  13. return args
  14. def main():
  15. args = parse_arguments()
  16. if args.new:
  17. keys = ("abcdefghijklmnopqrxtuvwsyz" + "ABCDEFGHIJKLMNOPQRXTUV" + "1234567890" + "~!@#$%^&*[]{}()")
  18. phrase = ("".join(random.sample(keys,16)))
  19. account = input("Account: ")
  20. username = input("Username: ")
  21. with open(password_file, 'a') as f:
  22. f.write("\n* " + account)
  23. f.write("\n- Username: " + username)
  24. f.write("\n- Pass: " + phrase)
  25. print(phrase + "\nDelete this now somehow")
  26. pyperclip.copy(phrase)
  27. if args.find:
  28. with open(password_file) as f:
  29. passwords = f.read()
  30. headers = passwords.split("* ")
  31. for line in headers:
  32. if args.find in line.split(" ")[0].split("\n-")[0].lower():
  33. print('\n'.join(line.replace("- ","").splitlines()))
  34. if __name__ == "__main__":
  35. main()