Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # password_strength_demo.py
- rate='Weak1 Weak2 Medium3 Medium4 Strong5 Strong6 Excellent'.split()
- bad='''^(){}[]'`";\/<> '''
- sym=list('!@#$%&*_+-=:~?,.')
- num=list('0123456789')
- def demo():
- p=''
- while 1:
- if p is '':
- p=raw_input("Enter New Password: ") # Replace raw_input with a text entry active bind in GUI
- if len(set([i in p for i in bad])) < 2 and '\t' not in p:
- s=4
- p=unicode(p)
- try:
- int(p)
- s=2; print 12345
- except:
- if (p.lower() is p) or (p.upper() is p): s=3
- elif len(set([i in p for i in num])) is 2: s=5
- t=len(set(list(p)))
- if t < 8: s-=1
- if t < 5: s-=1
- if len(p) < 6: s-=1
- if len(p) < 8: s-=1
- if len(p) < 10: s-=1
- if len(p) < 12: s-=1
- if len(set([i in p for i in sym])) is 2 and s > 4: s+=1
- if s < 0: s=0
- if s > 6: s=6
- print "Strength = %s (%s/6)" % (rate[s],s)
- if len(p) > 5:
- yn=raw_input("Submit Password? (Y/N) ")
- p=yn
- if len(yn) < 5:
- p=''
- try:
- if yn.split()[0].lower() in ('y','yes'):
- print "Password Submitted"
- break
- except: pass
- else: p=''
- else:
- print 'Sorry... spaces, tabs and all in the following... [ '+bad+']\n... are not acceptable.'
- p=''
- demo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement