Password Strength Checker — Using Python
The Real-World Problem: People often use weak passwords (Ex: “123456” or “password”) which are predictable and are prone to getting hacked.
Most of them aren’t sure what makes a password actually secure.
How it built in Python: Use string methods and conditional statements (for/if — else ladder) to check if a user-entered password meets simple rules — like being longer than 8 characters, containing at least 2 numbers, having 1 uppercase letter and has 1 Special character (# or @).
How does this work in background (Inside Python): When there is input taken from user, python determines the type of character in the “Input” using if, else loop. Characters are internally categorized as uppercase characters, special characters, numerical characters.
For Loop — Iterates through the entered password. That is, all the elements/values in the entered password undergo a check process. Like the check is done using if-elif-else (ladder) — to check if any of the entered values are in upper case, followed by checking any values are alphabetical or not, followed by checking if any of the values are numeric and last check is to confirm if any of the values are special character. If any of the cases are true the values of the respective dummy variable get added with ‘1’. Once all the variables get updated after completion of else loop, the if else loop runs a final check to confirm if values stored in dummy variable has met the requirement. If the requirement has been met, a message with confirmation regarding the password compatibility gets resulted to output and if not met, it results to error message with the requirements to confirm the correct password.
Referring to the snip above — Entered password “Welcome@12” contains — 2 digits, 1 special character and the length of the password is greater than 8 characters which matches with the password setting requirements for a normal use case.
Referring to the snip above-Entered password “welcome@123” does not contain uppercase characters and hence does not match the password setting requirements.
Get Yash Suresh Jaikar’s stories in your inbox
Join Medium for free to get updates from this writer.
Few example cases where password setting requirement has not been met.
Requirement of length of characters not met:
Requirement of number of special characters not met:
When entered password doesn't contain required number of numerical values.
When Uppercase characters are not available in the password
Conclusion: In today's world, where tech plays vital role in all of our daily usage and applications like phones password, emails password, UPI’s payments, desktop/laptop passwords, internet banking systems, social media account passwords and other technologies.
It is very mandatory that we use the correct formatting of the passwords and follow the basic steps of what a correct/valid password is.




