public static string NameEncryption(string name)
{
string tname = "";
char[] temp = new char[] { };
try
{
if (string.IsNullOrWhiteSpace(name))
{
throw new Exception();
//return "";
}
temp = name.ToCharArray();
if (temp.Length > 2)//多个字第二个加密
{
temp[1] = '*';
}
else if (temp.Length < 3 && temp.Length>1) //两个字第一个加密
{
temp[0] = '*';
}
tname = new string(temp); //一个字不加密
}
catch (Exception)
{
tname = name;
}
return tname;
}
C# 姓名加星号
最新推荐文章于 2023-06-16 16:53:23 发布