# -*- coding:utf-8 -*-
def myallin(input, check):
r = 1
for ch in input:
if not(ch in check): r = 0
return r
def myin(input, check):
for ch in input:
if ch in check: return 1
return 0
letter="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
num="0123456789"
char='~!@#$%^&*()_=-/,.?<>;:[]{}|\\'
passwd = input("请输入要检查的密码: ")
if (len(passwd)<=7):
print('输入的密码 {} 过短'.format(str(passwd)))
elif (len(passwd)>20): #假设最长20:
print('输入的密码 {} 过长'.format(str(passwd)))
elif myallin(passwd, letter) or myallin(passwd, num): #全是数字/字母
print('输入密码为高危')
elif myin(passwd, letter) and myin(passwd, num) and myin(passwd, char) and len(passwd)>=8: #包含字母数字符号并且长度>8
print('输入密码为低危')
else:
print('输入的密码为中危')
检查密码的安全性
猜你喜欢
转载自www.cnblogs.com/loveMelody/p/10004377.html
今日推荐
周排行