Today you will learn how to make a simple password checker in python. This is a perfect project for any beginner.
What are the minimum requirments for a good and secure password?
- Password length (min 8 characters)
- Numbers (1234)
- Upper cases (ABCD)
- Lower case (abcd)
- Special symbol (!@#$%)
def password_check(passwd):
SpecialSym =['!', '@', '#', '$', '%', '^', '&', '*']
val = True
if len(passwd) < 8:
print("Lengtt should be atleast 8 characters")
val = False
if len(passwd) > 20:
print("Password should not exeed 20 characters")
val = False
if not any(char.isdigit() for char in passwd):
print('Password should contain a digit')
val = False
if not any(char.isupper() for char in passwd):
print("Password should contain atleast 1 upper case")
val = False
if not any(char.islower() for char in passwd):
print("Password should contain atleast 1 lower case")
val = False
if not any(char in SpecialSym for char in passwd):
print("Password should contain 1 or more symbols like: !@$")
val = False
if val:
return val
def main():
passwd = input("Enter your password : ")
if (password_check(passwd)):
print("Password is valid")
else:
print("Invalid Password !!")
if __name__ == '__main__':
main()
If you liked this post and learned something new I would really appreciate it if you check out some of my other posts.
Excellent post. I was checking constantly this blog and I am impressed!
Extremely helpful information specially the last part 🙂 I care for such information a lot.
I was looking for this certain info for a long time.
Thank you and best of luck.