【发布时间】:2014-01-18 18:30:49
【问题描述】:
所以我为我、我的朋友和家人制作了一个小型密码强度测试器,如下所示:
import re
strength = ['You didnt type anything','Terrible','weak sause','avarage','Good!','Very Strong', 'THE FORCE IS STRONG WITH THIS ONE']
score = 1
password=(raw_input("please type in the password you would like rated:"))
if len(password) < 1:
print strength[0]
if len(password) >=1 and len(password)<=4:
print strength[1]
else:
print ""
if len(password) >=7:
score+=1
print "password was made stronger by not being short"
else:
print "Your password is really short, concider making it longer"
if len (password) >=10:
score+=1
print "password was made stronger by long"
else:
print "An even longer password would make it stronger"
if re.search('[a-z]',password) and re.search('[A-Z]', password):
score+=1
print "password was made stronger by having upper & lower case letters"
else:
print "Indlucing both upper and lower case letters will make your password stronger"
if re.search('[0-9]+', password):
score+=1
print "Password was made stronger by using numbers"
else:
print "Using numbers will make your password stronger"
if re.search('[.,!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]',password):
score+=1
print "Password was made stronger by using punctuation marks and characters"
else:
print "Using punctuation marks and characters will make the password stronger"
print "\n final password rating is:"
print strength[score]
我希望做的是:
第一个 - 为我提供给用户的密码内容的 cmets 添加颜色,好的 cmets 如:"password was made stronger by using numbers" 将有一个绿色输出,而建设性反馈如 "using numbers will make your password stronger" 将有一个红色输出,让用户更容易发现密码的优缺点
第二 - 我想知道,如果它的工作原理相同,我可以在上面的“强度”列表中为某些项目着色吗?让前两个红色,中间一对黄色,最后一对绿色?
ty!
【问题讨论】:
-
嘿,伙计——我实际上已经回答了这个问题,但由于它看起来像是一张空白纸上的颜色设置,我真的不明白如何将它合并到已经制作的代码中的特定行中。
-
拼写错误...如果您在意... sause = sauce, avage = 一般, concider = 考虑
-
我很在意,谢谢!这只是我在几分钟内完成的一件快事——还没有进行拼写检查。