Generate a strongest password on your own without any third-party apps.
We all use passwords to keep our account safe and secure so that it can be prevented from being attacked, but how can we achieve this? In order to make our password safe and secure, we need to use a password that can’t be guessed easily.
As per sources nearly 81% of online attacks are password related due to the poor password habits such as using a common password for different accounts, sharing credentials, and easily predictable password.
How can we create a strong password that is not easily guessable? There are several standards we need to follow.
- Inclusion of both upper-case and lower-case letters
- Inclusion of one or more numerical digits
- Inclusion of special characters such as @, #, $
- Prohibition of names, phone numbers, plate numbers
- Prohibition of personal information.
By Following this policy, we can set the strongest password that no one can guess.
Enough of lengthy definitions and descriptions. Let’s see how we can implement this in Python!!
For this, I have used two modules available from Python. They are
- Random Module.
- Array Module.
First things first, let’s import the two modules.
Next, we need to get the maximum length of the password from the user.
MAX_LEN = int(input("Enter the length of the Password : "))
Creating an Array to store the Alphanumeric characters and Symbols.
Combining the arrays and store it in a single variable.
combinedList= digits + upcaseCharacters + locaseCharacters + symbols
Next, randomly choosing one character from the array we just created.
randDigit = random.choice(digits)
randUpper = random.choice(upcaseCharacters)
randLower = random.choice(locaseCharacters)
randSymbol = random.choice(symbols)
Now, we create a temporary variable and add the randomly chosen Characters.
tempPass = randDigit + randUpper + randLower + randSymbol
Now we have random characters with the length of 4. To achieve the length we just got from the user, We are going to fill the list with random characters from the CombinedList variable.
Now we traverse the temp password array and append the characters and finally print the Password we generated.
Sample Input :
Enter the length of the password : 8Sample Output:
The output gets varied each and every time you run the code with different possibilities and Thats all folks! we just implemented a strong password generator using python.
You can find the whole code in my Github Repository. Drop a star if you find it useful.
You can play around and even explore more features. You can even make use of Python GUI using Tkinter.
Thanks for Reading, and do checkout my other blog
See you in next blog Article. Take Care