Advertisement
Programmin-in-Python

Minimum Characters required to create a Strong Password

Dec 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from string import ascii_uppercase, ascii_lowercase
  2.  
  3. def strongpass(n, password): # n -> length of 'password'; password ==> string containing the password
  4.     no_to_add = 0
  5.     upper, lower, no, spl = (False,)*4
  6.  
  7.     for i in password:
  8.         if i in ascii_uppercase:
  9.             upper = True
  10.         elif i in ascii_lowercase:
  11.             lower = True
  12.         elif i in "1234567890":
  13.             no = True
  14.         elif i in "!@#$%^&*()-+":
  15.             spl = True
  16.  
  17.     L1 = [upper, lower, no, spl]
  18.     no_to_add += L1.count(False)
  19.    
  20.     if (n + no_to_add) >= 6 :
  21.         return no_to_add
  22.     else:
  23.         return no_to_add + (6 - (n + no_to_add))
  24.  
  25. val = strongpass(1, "9")
  26. print(val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement