migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

67
web/App_Code/mask.cs Normal file
View File

@@ -0,0 +1,67 @@
using System.Linq;
using System.Text.RegularExpressions;
/// <summary>
/// 個資遮罩
/// 乎叫方式MyWeb.Mask.GetPersonalMask("王小明", "*");
/// </summary>
///
namespace MyWeb
{
public class Mask
{
public Mask()
{
}
static public string GetPersonalMask(string OriStr, string oPrefix)
{
return GetPersonalMask(OriStr, oPrefix, true);
}
static private string GetPersonalMask(string OriStr, string oPrefix, bool IsDis)
{
string oStr = "";
OriStr = OriStr.Trim();
char[] oStrArry = OriStr.ToCharArray();
int[] oArray = new int[] { 0, OriStr.Trim().Length - 1 };
if (Regex.IsMatch(OriStr.Trim(), @"^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"))
{
oStr += GetPersonalMask(OriStr.Split('@')[0], oPrefix) + "@";
for (int i = 0; i < OriStr.Split('@')[1].Split('.').Length; i++)
{
string oStrL = OriStr.Split('@')[1].Split('.')[i].ToString();
if (i == 0)
oStr += GetPersonalMask(oStrL, oPrefix, false);
else
oStr += "." + GetPersonalMask(oStrL, oPrefix, false);
}
return oStr;
}
else if (Regex.IsMatch(OriStr.Trim(), "^(09([0-9]){8})$"))
{
oArray = new int[] { 0, 1, 2, 7, 8, 9 };
}
else if (Regex.IsMatch(OriStr.Trim(), "^[a-zA-Z][0-9]{9}$"))
{
oArray = new int[] { 0, 1, 2, 3, 9 };
}
for (int i = 0; i < oStrArry.Length; i++)
{
if (IsDis)
oStr += oArray.Contains(i) ? oStrArry[i].ToString() : oPrefix;
else
oStr += oArray.Contains(i) ? oPrefix : oStrArry[i].ToString();
}
return oStr;
}
}
}