Simple Random Password Generator In Python
Are you like me and like to turn anything and everything into a script if possible? If so then here is another one for your collection. This is a random password generator in python that creates a password anywhere from 8 to 16 characters.
A strong password is usually your first line of defense against hackers or maybe your ex boyfriend or girlfriend. Always remember, the more complicated a password is, the harder it will be to guess or crack.
Download this python script on Github.
How it works
First we imported the string module. This module contains a number of functions to process standard Python strings.
Then we import randint and choice. Randint creates a pseudo-random number and choice() is an inbuilt function in the Python programming language that returns a random item from a list, tuple, or string.
Now we create a variable for letters, numbers, special characters and combine it all together in the chars variable.
We then set the minimum password length to 8 characters and the maximum to 16 characters. Feel free to change the password length to make the output more complex or straightfoward.
We combine it all together and print out the results. A new password will be generated every time the script is run.
We tested the password strength of “6H-361nr\m}_O” at Howsecureismypassword.net and received these results!
Feel free to leave a comment below with any suggestions or questions.
Interest In learning python?
Feel free to take a look at “Learning Python, 5th Edition“. Get a comprehensive, in-depth introduction to the core Python language with this hands-on book. Based on author Mark Lutz’s popular training course, this updated fifth edition will help you quickly write efficient, high-quality code with Python. It’s an ideal way to begin, whether you’re new to programming or a professional developer versed in other languages.
You’ll also learn some advanced language features that recently have become more common in Python code.
- Explore Python’s major built-in object types such as numbers, lists, and dictionaries
- Create and process objects with Python statements, and learn Python’s general syntax model
- Use functions to avoid code redundancy and package code for reuse
- Organize statements, functions, and other tools into larger components with modules
- Dive into classes: Python’s object-oriented programming tool for structuring code
- Write large programs with Python’s exception-handling model and development tools
- Learn advanced Python tools, including decorators, descriptors, metaclasses, and Unicode processing
This post “Create a Random Password Generator In Python” is located under the Programming Category
Learn how to create a Build a dynamic menu written in Powershell!