Advertisement
Blessing988

Untitled

Apr 23rd, 2020
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #Password Validator using regex
  2. import re
  3. while True:
  4.     print("Enter Password")
  5.     password = input(" ").strip()
  6.     pattern1 = r"[12345678097]"
  7.     pattern2 = r"[*#@!^#$%]"
  8.     pattern3 = r"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]"
  9.     if len(password) >=8:
  10.         if re.search(pattern3, password):
  11.             if re.search(pattern1, password):
  12.                 if re.search(pattern2, password):
  13.                     break
  14.                
  15.                 else:
  16.                     print("Password must contain special characters or symbols")
  17.                     continue
  18.                
  19.             else:
  20.                 print("Password must contain numbers")
  21.                 continue
  22.         else:
  23.             print("Password must contain letters")
  24.             continue
  25.            
  26.     else:
  27.         print("Password too short")
  28.         continue
  29.        
  30. print("Valid Password")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement