Secure Password Generator with Python

The average person in the US spends over 8 hours online per day. A lot of that time is spent on secure sites that require a password. Email, bank accounts, social media and so on. Four out of five breaches are somehow linked to passwords. A study by Verizon, concerning breaches involving hacking, states that 80% of breaches are caused by passwords. What many people don’t realize is how easy it is for a bad actor to crack a short, simple password. I know plenty of people that will create a password using known/ easily researchable things ie family members names, birthdates, phone numbers and so on.

The NIST National Institute of Standards and Technology, has 3 password guidelines for creating a secure password, long length, complex and random. The combination of those three will help prevent yourself from getting hacked. Below I have provided an image just to show how easy it can be for a bad actor to brute force your account and the length it will take with a good complex password.

In organizations I worked for in the past the recommendation was 12 characters, this year that was upped to 14 which is also recommended by the NIST. If you’re like me then coming up with a complex 14 long password is no easy feat but luckily for us we have the convenience of programming to help us generate a complex password.

Writing all of this up took 10 minutes and as I am a python novice, it shouldn’t take you anymore as well. This simple script will provide you with a randomly generated password that fits the criteria for security, long length, complex and random.

This first line is the random function. This is a library of functions that is built into python and extends the basic features of python. Sometimes we may want the computer to pick a random number, letter, symbol in a given range and the Random Module provides access that supports this.

These next lines create a bunch of strings that contain all possible characters we will use for our password generator.

Next we’re going to create a boolean for all the things we want to include in the password. Boolean is one of Pythons built in data types that is used to express the truth value of an expression. You can change the trues to false later if you’d like but for now I’m setting everything as true. Upper for uppercase, lower for lowercase and so on.

Now the next thing we need to do is create a string containing all the things that we’re going to use. This will tie our strings in.

Next we will set the length of the password, and how many passwords we will want generated at once. Im going with the NIST recommended 14 characters as this is a showcase on secure passwords.

So now that we’ve doin that we’ll be writing our next string using the Python Join function which joins elements and returns the combined string. The “all” will grab all the characters we’re using and the “length” will determine the amount of characters to be used. The “Print()” function will return the specified passwords .

Now once done, you can run this command and it should return passwords for your use.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial