C#中判断密码字符强度 并设置对应颜色
来源:互联网 发布:国际贸易数据 编辑:程序博客网 时间:2024/05/01 21:37
C#中判断密码字符强度 并设置对应颜色
1.判断字符强度并返回等级1-弱,2-中,3-强,4-安全
private int CodeLevel(string str)
{
int level = 0;
int ilowchar = 0; //是否包含小写字母
int icapchar = 0; //是否包含大写字母
int inum = 0; //是否包含数字
int iother = 0; //是否包含特殊字符
if (str.Count() < 6)
{
level = 0; //等级低
return level;
}
else
{
foreach (char c in str)
{
int ic = Convert.ToInt32(c);
if (ic >= 48 && ic <= 57) //数字
{
inum = 1;
}
else if (ic >= 65 && ic <= 90) //大写字母
{
icapchar = 1;
}
else if(ic >= 97 && ic <= 122) //小写字母
{
ilowchar = 1;
}
else //其他字符
{
iother = 1;
}
}
}
level = ilowchar + icapchar + inum + iother;
return level;
}
2.根据返回值不同去设置不同的显示
switch (CodeLevel(str))
{
case 1:
progress_pas.Value = 25;
progress_pas.Foreground = new SolidColorBrush(Color.FromArgb(255, 224, 240, 135));
break;
case 2:
progress_pas.Value = 50;
progress_pas.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
break;
case 3:
progress_pas.Value = 75;
progress_pas.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 153, 0));
break;
case 4:
progress_pas.Value = 100;
progress_pas.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 204, 0));
break;
default:
progress_pas.Value = 0;
break;
}
- C#中判断密码字符强度 并设置对应颜色
- java判断密码强度,判断字符在字符串中出现的次数
- JavaScript密码强度判断
- javascript密码强度判断
- js判断密码强度
- IOS密码强度判断
- jQuery判断密码强度
- jQuery判断密码强度
- js判断密码强度
- 密码强度判断,弱中强
- JavaScript判断密码强度
- JS判断密码强度
- php判断密码强度
- php判断密码强度
- jQuery判断密码强度
- 密码强度判断
- 判断密码强度
- 判断密码强度
- nfs常见问题解决方法
- linux的启动过程以及/etc/inittab详解
- 为什么要使用信道复用技术?常用的信道复用技术有哪些?
- 常用算法之动态规划法
- c3p0出现 An attempt by a client to checkout a Connection has timed out
- C#中判断密码字符强度 并设置对应颜色
- java自带线程池和队列详细讲解
- 怎样让机器学会检测人脸——4、AdaBoost
- storm知识
- 关键路径计算、总时差、自由时差
- java 搭建webservice服务+test客户端测试
- 数据链路层的有那三个基本问题?为什么都必须加以解决?
- 受谷歌和微软夹击,亚马逊云计算营收规模增长放缓
- Android中measure过程、WRAP_CONTENT详解以及xml布局文件解析流程浅析