Parser.add_argument("-t", "-total-length", type=int, Next, if the user wants to instead pass the total number of characters of the password, and doesn't want to specify the exact number of each character type, then the -t or -total-length argument handles that: # add total pw length argument Parser.add_argument("-s", "-special-chars", default=0, help="Number of special chars in the PW", type=int) Parser.add_argument("-u", "-uppercase", default=0, help="Number of uppercase chars in the PW", type=int) Parser.add_argument("-l", "-lowercase", default=0, help="Number of lowercase chars in the PW", type=int) Parser.add_argument("-n", "-numbers", default=0, help="Number of digits in the PW", type=int) The first four will be the number of each character type numbers, lowercase, uppercase, and special characters, we also set the type of these arguments as int: # Adding the arguments to the parser We continue by adding arguments to the parser. This information will appear if the user provides the -h argument when running our program, it will also tell them the available arguments: # Setting up the Argument Parserĭescription='Generate any number of passwords with this tool.' We give the parser a name and a description. To do this, we create a new instance of the ArgumentParser class to our parser variable. Now we continue with setting up the argument parser. Get: Build 24 Ethical Hacking Scripts & Tools with Python Book Setting up the Argument Parser Check this tutorial that covers generating random data with these modules. If you're not sure how the random and secrets modules works. We don't have to install any of these because they come with Python: from argparse import ArgumentParser We also get the string module which just has some collections of letters and numbers. For this program, we just need the ArgumentParser class from argparse and the random and secrets modules. We will use the argparse module to make it easier to parse the command line arguments the user has provided. In this tutorial, we will make a command-line tool in Python for generating passwords. Tkinter is used to create the program’s GUI, while the random and string modules are used to randomly select characters to use.Password generators are tools that allow the user to create random and customized strong passwords based on preferences. This project focuses on using the Tkinter and random libraries to create new passwords. These are the concepts that you will use and build upon as you code this project. At this point, you should already know the basics of creating functions, installing packages, and creating simple GUIs (graphical user interfaces) with Tkinter. This is an intermediate-level project for those who are new to Python. Whether you are new to Python or have some prior experience, this project is a great way to learn more about making functional programs and helps you apply your knowledge in a practical and fun way. Users will select the number of characters they want their password to be, and the program will create one using upper and lowercase letters, numbers, and symbols. That’s why in this article we are going to be creating a program to automatically generate a secure password that will help keep your private information safe.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |