In the 21st century your password is one of the major keys anyone can use to break into nearly every facet of your life. Whether it be a bank account, email or social media it's very important to make sure that your passwords are kept strong and well protected. The main components of a strong password are, length, uncommon phrases and variability of the characters in your password. So since most keyboards have at least 94 different characters on them, it's in your best interest to leverage them.
So for our password generator we'll create a Python file that will create a password that's 25 characters long.
First off we have to import some libraries in order to help us make this project. The first lines of could you should write is
import random, string
These libraries will help us generate random values for our password and concatenate Strings to create a password we can use.
Next we create a variable of how long we want our password to be and this is changeable if you want your password to be longer or shorter. I'm just going to set mine to 20.
passLength = 20
Next up we have to create a variable that holds every character that we need, and this is where those 2 libraries come in. It would be a major pain to write out all of the possible choices by hand, so if we write out these constants it will easily create a list of possible characters we can use.
passCharacterChoices = string.ascii_letters + string.punctuation + string.digits
Then you have to make a blank list variable to hold your generated password as well as a for loop to add the characters to the password. We'll be using the .append function for this.
password =  for x in range(passLength): password.append(random.choice(passCharacterChoices))
Finally you just have to print the list as a combined string using the print and join method and you'll have an easy to use Password Generator.
Overall your entire code should look like this
import random, string passLength = 20 passCharacterChoices = string.ascii_letters + string.punctuation + string.digits password =  for x in range(passLength): password.append(random.choice(passCharacterChoices)) print(''.join(password))
Voila, your own password generator! In part 2 we'll add more inputs that you can make in order to create specific types of passwords that might be longer or shorter as well as having specific characters included or not included. So be on the look out for that.