diff --git a/README.md b/README.md index 82f6e54..7ac2c72 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,51 @@ -# password-generator -Generates Strong Random Password. +# Password Generator + Generates Strong Random Password. + +### Supports Platform: Cross Platform + +### Programming Language: Python 3 and above + +### How to use: + 1. If you have *Python3* installed. You can use the `.py` file. Make sure to install `pyperclip` package - `python -m pip install pyperclip`. + - For *Windows*, use [generate_password_no_color.py][1] file. + - For *Linux/macOS*, you can use any `.py` file. But if you are using colored version i.e., [generate_password.py][2] make sure you install, *termcolor* package (`python -m pip install termcolor`) in Python. + - For *Linux*, you need to install `xclip` using command - `sudo apt install xclip` + +2. You can use **binaries/executable** version as well. + - Binaries are in [executables][6] folder. + - For ***Windows*** -> [Download][3] + - For ***macOS*** -> [Download][5] + - After downloading, paste the file in `Documents` folder and open **Terminal/Command Prompt**. + - Enter the command, `cd Documents`. + - Run the file by typing `./` followed by file name. For eg., `./generate_password.exe` (for Windows) and `./generate_password` (for macOS). + +**Note:** On *macOS*, before running the file, you might need to run `chmod 755 generate_password` to make it *executable*. + +### Available Arguments: + - **-h or --help:** *Displays all the available options.* + - **-c or --copy:** *Optional. Specifying this option will copy the generated password to clipboard.* + - **-l or --length:** *Optional. This option can be used to specify the length of the password. If this option is not used default length will be 12.* + +### Color Significance: + - **Green:** Successful. + - **Blue:** In process. + - **Red:** Unsuccessful or Errors. + - **Yellow:** User Input. + +### Licensed: GNU General Public License, version 3 + +### Developer Information: +- **Website:** https://www.hackhunt.in/ +- **Contact:** hh.hackunt@gmail.com +- **LinkedIn:** https://www.linkedin.com/company/hackhunt +- **Youtube:** [@hackhunt](https://youtube.com/hackhunt) +- **Instagram:** [@hh.hackhunt](https://www.instagram.com/hh.hackhunt/) +- **Facebook:** [@hh.hackhunt](https://www.facebook.com/hh.hackhunt/) +- **Twitter:** [hh_hackhunt](https://twitter.com/hh_hackhunt/) +- **Patreon:** [@hackhunt](https://www.patreon.com/hackhunt) + +[1]: ./generate_password_no_color.py +[2]: ./generate_password.py +[3]: ./executables/windows/ +[5]: ./executables/mac/ +[6]: ./executables/ diff --git a/executables/mac/generate_password b/executables/mac/generate_password new file mode 100644 index 0000000..ebe79a6 Binary files /dev/null and b/executables/mac/generate_password differ diff --git a/executables/windows/generate_password.exe b/executables/windows/generate_password.exe new file mode 100644 index 0000000..de106c0 Binary files /dev/null and b/executables/windows/generate_password.exe differ diff --git a/generate_password.py b/generate_password.py new file mode 100644 index 0000000..c6fc493 --- /dev/null +++ b/generate_password.py @@ -0,0 +1,80 @@ +#! /usr/bin/env python3 + +import argparse +from random import sample as select_random +from pyperclip import copy +from termcolor import colored + + +def generate_password(pass_length): + + print(colored("\n[+] Generating Random Password...", 'blue')) + + lower_alphabets = "qwertyuiopasdfghjklmnbvcxz" + upper_alphabets = lower_alphabets.upper() + digits = '0123456789' + punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' + + combination = list("{0}{1}{2}{3}".format(lower_alphabets, upper_alphabets, digits, punctuation)) + password = select_random(combination, pass_length) + password = "".join(password) + + return password + + +def get_arguments(): + parser = argparse.ArgumentParser(prog="Password Generator", + usage="%(prog)s [options]\n\t[-l | --length] [number]", + formatter_class=argparse.RawDescriptionHelpFormatter, + description=""">>> | Password Generator v1.0 by Hack Hunt | <<< + ----------------------------------------""") + + parser._optionals.title = "Optional Argument" + + parser.add_argument('-l', '--length', + dest='pass_length', + metavar='', + type=int, + default=12, + help='Specify the password length. Default is 12.') + + parser.add_argument('-c', '--copy', + dest='copy', + action='store_true', + help='If specified, the password will be copied to clipboard.') + + args = parser.parse_args() + return args + + +def main(): + args = get_arguments() + pass_length = args.pass_length + copy_clipboard = args.copy + + try: + while True: + password = generate_password(pass_length) + print(colored("[+] Password generated successfully -> {0}".format(password), 'green')) + + option = input(colored("\nAre you satisfied? [Y/N] (Default - Y)", 'yellow') + "\n>>> ").lower() + + if option not in ['n', 'no']: + break + + if copy_clipboard: + copy(password) + print(colored("\n[+] Generated Password has been copied to clipboard", 'green')) + else: + print(colored("\n[!] Password is not copied to clipboard, make sure to copy it.", 'red')) + + except KeyboardInterrupt: + print(colored("\n[+] User interrupted. Exiting...", 'red')) + + except BaseException as e: + print(colored("\n[-] Error: {0}".format(e), 'red')) + + +##################################################### +if __name__ == '__main__': + main() diff --git a/generate_password_no_color.py b/generate_password_no_color.py new file mode 100644 index 0000000..a846344 --- /dev/null +++ b/generate_password_no_color.py @@ -0,0 +1,79 @@ +#! /usr/bin/env python3 + +import argparse +from random import sample as select_random +from pyperclip import copy + + +def generate_password(pass_length): + + print("\n[+] Generating Random Password...") + + lower_alphabets = "qwertyuiopasdfghjklmnbvcxz" + upper_alphabets = lower_alphabets.upper() + digits = '0123456789' + punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' + + combination = list("{0}{1}{2}{3}".format(lower_alphabets, upper_alphabets, digits, punctuation)) + password = select_random(combination, pass_length) + password = "".join(password) + + return password + + +def get_arguments(): + parser = argparse.ArgumentParser(prog="Password Generator", + usage="%(prog)s [options]\n\t[-l | --length] [number]", + formatter_class=argparse.RawDescriptionHelpFormatter, + description=""">>> | Password Generator v1.0 by Hack Hunt | <<< + ----------------------------------------""") + + parser._optionals.title = "Optional Argument" + + parser.add_argument('-l', '--length', + dest='pass_length', + metavar='', + type=int, + default=12, + help='Specify the password length. Default is 12.') + + parser.add_argument('-c', '--copy', + dest='copy', + action='store_true', + help='If specified, the password will be copied to clipboard.') + + args = parser.parse_args() + return args + + +def main(): + args = get_arguments() + pass_length = args.pass_length + copy_clipboard = args.copy + + try: + while True: + password = generate_password(pass_length) + print("[+] Password generated successfully -> {0}".format(password)) + + option = input("\nAre you satisfied? [Y/N] (Default - Y)\n>>> ").lower() + + if option not in ['n', 'no']: + break + + if copy_clipboard: + copy(password) + print("\n[+] Generated Password has been copied to clipboard") + else: + print("\n[!] Password is not copied to clipboard, make sure to copy it.") + + except KeyboardInterrupt: + print("\n[+] User interrupted. Exiting...") + + except BaseException as e: + print("\n[-] Error: {0}".format(e)) + + +##################################################### +if __name__ == '__main__': + main()