隐藏身份证号中间位数

+ (NSString*)idCardToAsterisk:(NSString *)idCardNum

{

NSInteger length = idCardNum.length;

return [idCardNum stringByReplacingCharactersInRange:NSMakeRange(6, 8) withString:@"********"];

}

+ (NSString *)userNameToAsterisk:(NSString *)realName

{

NSInteger length = realName.length;

return [realName stringByReplacingCharactersInRange:NSMakeRange(length-1,1) withString:@"*"];

}

+ (NSString *)investPersonNameToAsterisk:(NSString *)personName

{

NSInteger length = personName.length;

if (length == 11) {

return [personName stringByReplacingCharactersInRange:NSMakeRange(3,length-7) withString:@"****"];

}

else if (length >= 5 && length < 11)

{

return [personName stringByReplacingCharactersInRange:NSMakeRange(3,length-3) withString:@"****"];

}

else

{

return [personName stringByReplacingCharactersInRange:NSMakeRange(1,length-1) withString:@"****"];

}

}

你可能感兴趣的:(隐藏身份证号中间位数)