IOS 计算密码强度
+ (BOOL) judgeRange:(NSArray*)conditionArr Password:(NSString*)password
{
NSRange range;
BOOL result =NO; for(int i=; i<[conditionArr count]; i++)
{
range = [password rangeOfString:[conditionArr objectAtIndex:i]];
if(range.location != NSNotFound)
{
result =YES;
}
}
return result;
} //条件
+ (NSString*)judgePasswordStrength:(NSString*)password
{
NSMutableArray* resultArray = [[NSMutableArray alloc] init]; NSArray* termArray1 = [[NSArray alloc] initWithObjects:@"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", @"j", @"k", @"l", @"m", @"n", @"o", @"p", @"q", @"r", @"s", @"t", @"u", @"v", @"w", @"x", @"y", @"z", nil];
NSArray* termArray2 = [[NSArray alloc] initWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil];
NSArray* termArray3 = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];
NSArray* termArray4 = [[NSArray alloc] initWithObjects:@"~",@"`",@"@",@"#",@"$",@"%",@"^",@"&",@"*",@"(",@")",@"-",@"_",@"+",@"=",@"{",@"}",@"[",@"]",@"|",@":",@";",@"“",@"'",@"‘",@"<",@",",@".",@">",@"?",@"/",@"、", nil]; NSString* result1 = [NSString stringWithFormat:@"%d",[self judgeRange:termArray1 Password:password]];
NSString* result2 = [NSString stringWithFormat:@"%d",[self judgeRange:termArray2 Password:password]];
NSString* result3 = [NSString stringWithFormat:@"%d",[self judgeRange:termArray3 Password:password]];
NSString* result4 = [NSString stringWithFormat:@"%d",[self judgeRange:termArray4 Password:password]]; [resultArray addObject:[NSString stringWithFormat:@"%@",result1]];
[resultArray addObject:[NSString stringWithFormat:@"%@",result2]];
[resultArray addObject:[NSString stringWithFormat:@"%@",result3]];
[resultArray addObject:[NSString stringWithFormat:@"%@",result4]]; int intResult=;
for (int j=; j<[resultArray count]; j++)
{
if ([[resultArray objectAtIndex:j] isEqualToString:@""])
{
intResult++;
} } NSString* resultString = [[NSString alloc] init];
if (intResult == )
{
resultString = @"密码强度低,建议修改";
} else if (intResult == && [password length]>= )
{
resultString = @"密码强度一般";
}
if (intResult == &&[password length]>)
{
resultString = @"密码强度高"; }
return resultString; }
IOS 计算密码强度的更多相关文章
- Javascript计算密码的强度
用Javascript评估用户输入密码的强度 1.如果密码少于5位,那么就认为这是一个弱密码.2.如果密码只由数字.小写字母.大写字母或其它特殊符号当中的一种组成,则认为这是一个弱密码.3.如果密码由 ...
- js判断密码强度
html代码: <form name="form1" action=""> 密码:<input type="password&quo ...
- javascript密码强度验证!
//CharMode函数 //测试某个字符是属于哪一类 function CharMode(iN) { if (iN>=48 && iN <=57) //数字 return ...
- 密码强度的js插件(完成)
效果如下图: 低:
- 一个玩具程序——测试密码强度(pure C)
替人写的C语言作业… 介绍: 程序名称:密码强度检测程序 注释风格:doxygen 测试环境:linux3.6, gcc4.7window7, vs2012 已知问题:1. 算法与参考链接不一致,结果 ...
- Js判断密码强度并显示提示信息
用javascipt实现的Ajax判断密码强弱的功能,大多数有用户注册功能的网站,都会有这么一个功能,作为WEB程序员,应该会写这种小模块哦,不懂的就看下这个例子,觉得挺简单,当初帮助了不少人学会了密 ...
- javascript 检测密码强度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js实现密码强度验证
<html> <head> <meta http-equiv="content-type" content="text/html" ...
- javascript 按位或(|),无符号右移(>>>)运算,组合技巧来实现————密码强度提示,四种情况??
直接上代码,原来的代码中,switch中的第一个case,判断之后,少加了个break 跳出判断语句,害得我查了半天,“怎么样式老是不对,不科学啊,呵呵,原来是没跳出case的判断了,还会执行后面的判 ...
随机推荐
- Rhythmbox中文乱码解决的方法
转自:http://hi.baidu.com/morgensonne/item/3470aef58747abde6325d2d9 今天在网络上找到了一个比較好的解决Rhythmbox中文乱码的问题的方 ...
- Vijos1051. 送给圣诞夜的极光
试题请參见: https://vijos.org/p/1051 题目概述 圣诞老人回到了北极圣诞区, 已经快到12点了. 也就是说极光表演要開始了. 这里的极光不是极地特有的自然极光景象. 而是圣诞老 ...
- iOS8 Core Image In Swift:更复杂的滤镜
iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...
- sql语句中BEGIN TRAN...COMMIT TRAN
BEGIN TRAN标记事务開始 COMMIT TRAN 提交事务 一般把DML语句(select ,delete,update,insert语句)放在BEGIN TRAN...COMMIT TR ...
- 微信jssdk批量展示卡包中的卡券
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- Android生命周期注意事项
生命周期图解 以下英文引用全部来自google官方文档说明,方便理解. onCreate (Bundle savedInstan ...
- Unix is 命令
输入正整数n以及n个文件名,排序后按列优先的方式左对齐输出.假设最长文件名有M字符,则最右列有M字符,其他列都是M+2字符. 附加条件每行最多输出60个字符,在此条件下要求行最少. Sample in ...
- (译+原)std::shared_ptr及std::unique_ptr使用数组
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5462363.html 参考网址: http://stackoverflow.com/questions ...
- C# 导出Excel Aspose.Cells
public void ExportExcel() { Workbook workbook = new Workbook(); //工作簿 workbook.Worksheets.Clear(); w ...
- zend framework 初识
1. 请求顺序 : index.php --> Bootstrap.php --> IndexController.php 2. 验证顺序 : Bootstrap.php function ...