+ (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 计算密码强度的更多相关文章

  1. Javascript计算密码的强度

    用Javascript评估用户输入密码的强度 1.如果密码少于5位,那么就认为这是一个弱密码.2.如果密码只由数字.小写字母.大写字母或其它特殊符号当中的一种组成,则认为这是一个弱密码.3.如果密码由 ...

  2. js判断密码强度

    html代码: <form name="form1" action=""> 密码:<input type="password&quo ...

  3. javascript密码强度验证!

    //CharMode函数 //测试某个字符是属于哪一类 function CharMode(iN) { if (iN>=48 && iN <=57) //数字 return ...

  4. 密码强度的js插件(完成)

    效果如下图: 低:

  5. 一个玩具程序——测试密码强度(pure C)

    替人写的C语言作业… 介绍: 程序名称:密码强度检测程序 注释风格:doxygen 测试环境:linux3.6, gcc4.7window7, vs2012 已知问题:1. 算法与参考链接不一致,结果 ...

  6. Js判断密码强度并显示提示信息

    用javascipt实现的Ajax判断密码强弱的功能,大多数有用户注册功能的网站,都会有这么一个功能,作为WEB程序员,应该会写这种小模块哦,不懂的就看下这个例子,觉得挺简单,当初帮助了不少人学会了密 ...

  7. javascript 检测密码强度

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. js实现密码强度验证

    <html> <head> <meta http-equiv="content-type" content="text/html" ...

  9. javascript 按位或(|),无符号右移(>>>)运算,组合技巧来实现————密码强度提示,四种情况??

    直接上代码,原来的代码中,switch中的第一个case,判断之后,少加了个break 跳出判断语句,害得我查了半天,“怎么样式老是不对,不科学啊,呵呵,原来是没跳出case的判断了,还会执行后面的判 ...

随机推荐

  1. PHP文件目录copy

    /**(2) PHP文件目录copy @param string $dirsrc 原目录名称字符串 @param string $dirto 目标目录名称字符串 */ function copyDir ...

  2. Android FragmentActivity onActivityResult冲突问题

    场景:假设fragment的填充数据是ListView,ListView中的每一项都有button,点击每一项的button跳转到B界面.在B界面处理完业务需返回fragment中更新数据. 解决方式 ...

  3. jstl数字保留两位小数

    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><fmt:fo ...

  4. 如何排版 微信公众号「代码块」之 MarkEditor

    前段时间写过一篇文章 如何排版微信公众号「代码块」,讲的是如何使用浏览器插件 Markdown Here 来排版代码块.虽然用 Markdown Here 排版出来的样式还不错,但存在一个问题,就是代 ...

  5. 对list代理扩展功能

    package 动态代理扩展List; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; imp ...

  6. 0112.1——iOS开发之理解iOS中的MVC设计模式

    模型-视图-控制器(Model-View-Controller,MVC)是Xerox PARC在20世纪80年代为编程语言Smalltalk-80发明的一种软件设计模式,至今已广泛应用于用户交互应用程 ...

  7. UIScrollView的基本使用和一些常用代理方法

    - (void)viewDidLoad { [super viewDidLoad]; scrollView = [[UIScrollView alloc] initWithFrame:CGRectMa ...

  8. 从C# String类理解Unicode(UTF8/UTF16)

    上一篇博客:从字节理解Unicode(UTF8/UTF16).这次我将从C# code 中再一次阐述上篇博客的内容. C# 代码看UTF8 代码如下: string test = "UTF- ...

  9. Struts2学习笔记 国际化(Internationalization)

    概述 国际化(Internationalization),通途的讲,就是让软件实现对多种语言的支持.可以通过简单的设置就可以从一种语言切换到另一种语言.用的最多的地方就是在应用程序的界面表示上.我们经 ...

  10. ARM编译空间属性(转)

    原文地址:http://www.cnblogs.com/hongzg1982/articles/2205093.html 1. 程序的空间属性 一般情况下,一个程序本质上都是由 bss段.data段. ...