- (NSString *)checkPassWord1:(NSString *)passWord1 WithPassWord2:(NSString *)passWord2 WithUsername:(NSString *)uesrname {
if ([passWord1 isEqualToString:passWord2]) {
NSRange range = [passWord1 rangeOfString:@" "];
if (range.location != NSNotFound) {
return @"不能有空格";
}else {
if (passWord1.length >=6 && passWord1.length <=20) {
NSString *passWordRegex = @"^(?=.*[a-zA-Z0-9].*)(?=.*[a-zA-Z\\W].*)(?=.*[0-9\\W].*).{8,20}$";//至少使用两种字符组合
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", passWordRegex];
if ([pred evaluateWithObject:passWord1]) {
if ([passWord1 isEqualToString:uesrname]) {
return @"密码与用户名相同,有被盗风险" ;
}else {
return @"";
}
}else {
return @"至少使用两种字符组合";
}
} else {
return @"长度只能在8-20个字符之间";
}
}
} else {
return @"两次输入密码不一致,请重新输入";
}
}
网友评论