当前位置:网站首页>课堂作业--密码强度判断
课堂作业--密码强度判断
2022-08-08 06:22:00 【掉发小丸子】
用户输入一个字符串做为密码,判断密码强度,规则为:密码长度小于8弱密码,密码长度大于等于8且包含至少2种字符为中等强度、密码包含3种字符为强、包含全部4种字符为极强。
提示:
string.digits 可返回’0123456789’
string.ascii_lowercase 可返回’abcdefghijklmnopqrstuvwxyz’
string.ascii_uppercase 可返回’ABCDEFGHIJKLMNOPQRSTUVWXYZ’
string.punctuation 可返回’!"#$%&’()*+,-./:;<=>[email protected][\]^_`{|}~’
import string
a=list(input(""))
digits=[]
ascii_lowercase=[]
ascii_uppercase=[]
punctuation=[]
count=0
if len(a)<8:
print("弱")
elif len(a)>=8:
for i in a:
if i in string.digits :
digits.append(i)
if i in string.ascii_lowercase :
ascii_lowercase.append(i)
if i in string.ascii_uppercase :
ascii_uppercase.append(i)
if i in string.punctuation:
punctuation.append(i)
#判断运用了哪些字符方式,并用标志count表示
if digits:
count=count+1
if ascii_lowercase:
count=count+1
if ascii_uppercase:
count=count+1
if punctuation:
count=count+1
#通过count的值可以知道运用了多少种,以此来判断强度
if count==2:
print("中")
if count==3:
print("强")
if count==4:
print("极强")
结果:
123sdf
弱
***Repl Closed***
12345678Aa!
极强
***Repl Closed***
边栏推荐
猜你喜欢
随机推荐
chmod +x 的含义,为什么要chmod +x
有哪些可以“躺平”的技术开发岗位?------音视频开发畅谈
四面拿下字节2-2Offer,入职就是...
简要概述深度学习和机器学期的区别
YoloV4训练自己的数据集(二)
原型与原型链
人机对话中得意图识别(关键词提取,svm工具)
MySQL数据库
机器学习,信用卡项目(二分类问题)完整代码 + 详细注释
七千字带你了解封装等机制
黑苹果安装
Pit Filling Simulated Hash Table
screen 命令修改默认快捷键ctrl + a
我的第一篇博客
Runtime - KVC, KVO principle
unordered_map 在读写锁下多线程潜在的core 问题
使用XGboost进行分类,判断该患者是否患有糖尿病
MySQL database
form表单,formdata对象,实现文件上传
oracle的插入sql错误









