📄 identify.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
//MD5加密
using System.Security.Cryptography;
//正则表达式
using System.Text.RegularExpressions;
namespace BMS
{
class Identify
{ //MD5加密法
public static string MD5(String str)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(str);
byte[] result = md5.ComputeHash(data);
String ret = "";
for (int i = 0; i < result.Length; i++)
ret += result[i].ToString("x").PadLeft(2, '0');
return ret;
}
//验证身份证(15位或18位)
public static bool IdentifyCard(string str)
{
return Regex.IsMatch(str, "\\d{15}|\\d{18}");
}
//验证员工编号(8位)
public static bool Number(string str)
{
return Regex.IsMatch(str, "\\d{8}");
}
//验证电话(座机为11位或12位,手机为11位)
public static bool Phone(string str)
{
return Regex.IsMatch(str, "\\d{3}-\\d{8}|\\d{4}-\\d{7}|\\d{11}");
}
//验证密码长度是否正确(6位)
public static bool Pwd(string str)
{
return Regex.IsMatch(str, "\\d{6}");
}
public static bool Ename(string str)
{
return Regex.IsMatch(str, "\\S{10}");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -