一个暗藏IP地址最后一位的方法
一个隐藏IP地址最后一位的方法
用法
Text.IP("192.168.0.1", 1); 结果 192.168.0.*
Text.IP("192.168.0.1", 2); 结果 192.168.*.*
Text.IP("192.168.0.1", 3); 结果 192.*.*.*
-------
www.40ps.com 网站建设,程序定做,发布站程序开发,论坛建设等服务
// 摘要: // 隐藏IP。 // 参数: // ip : 需要隐藏的IP。 // n : 隐藏的位数。 public static string IP(string ip, int n) { if(string.IsNullOrEmpty(ip)) { return string.Empty; } string[] ary = ip.Split('.'); int length = Text.GetArrayLength(ary); string result = ary[0]; for (int i = 1; i < length; i++) { if(i + 1 > length - n) { result = result + ".*"; } else { result = result + "." + ary[i]; } } return result; }
用法
Text.IP("192.168.0.1", 1); 结果 192.168.0.*
Text.IP("192.168.0.1", 2); 结果 192.168.*.*
Text.IP("192.168.0.1", 3); 结果 192.*.*.*
-------
www.40ps.com 网站建设,程序定做,发布站程序开发,论坛建设等服务