身份证校验
来源:互联网 发布:java访问https 编辑:程序博客网 时间:2024/05/01 03:19
/** * 身份证校验 * * @param cardNo 待校验身份证号码 * * @return BOOL YES/NO */+(BOOL)checkIdentityCardNo:(NSString*)cardNo{ if (cardNo.length != 18) { return NO; } NSArray* codeArray = [NSArray arrayWithObjects:@"7",@"9",@"10",@"5",@"8",@"4",@"2",@"1",@"6",@"3",@"7",@"9",@"10",@"5",@"8",@"4",@"2", nil]; NSDictionary* checkCodeDic = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1",@"0",@"X",@"9",@"8",@"7",@"6",@"5",@"4",@"3",@"2", nil] forKeys:[NSArray arrayWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10", nil]]; NSScanner* scan = [NSScanner scannerWithString:[cardNo substringToIndex:17]]; int val; BOOL isNum = [scan scanInt:&val] && [scan isAtEnd]; if (!isNum) { return NO; } int sumValue = 0; for (int i =0; i<17; i++) { sumValue+=[[cardNo substringWithRange:NSMakeRange(i , 1) ] intValue]* [[codeArray objectAtIndex:i] intValue]; } NSString* strlast = [checkCodeDic objectForKey:[NSString stringWithFormat:@"%d",sumValue%11]]; if ([strlast isEqualToString: [[cardNo substringWithRange:NSMakeRange(17, 1)]uppercaseString]]) { return YES; } return NO;}
阅读全文
0 0
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 身份证校验
- 校验身份证
- 身份证校验
- Javascript身份证校验(原创)
- 身份证校验[pb源码]
- JS 身份证校验函数
- 身份证JS校验
- 移动设备,点击事件生效,但是touch事件未生效.
- python 中if __name__ == '_main_':解析
- 操作系统字符集修改
- 打算进军github!
- 文章链接
- 身份证校验
- 解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No s
- mysql 查询一小时之内的数据
- Apache Spark 的安装
- Myeclipse 8.5破解方法
- 高级表单、表格+bfc讲解与使用
- 区块链开发底层交易虚拟币的找零机制是什么?
- Apache Storm 的安装
- 数组必知道的几个操作