搜尋身份證號, 電話功能選項
This commit is contained in:
@@ -127,6 +127,67 @@ namespace MyWeb
|
||||
char.IsLetterOrDigit(c)).ToArray()).ToUpper();
|
||||
return SHA256(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成 search_keywords 的 HEX 編碼字串
|
||||
/// </summary>
|
||||
/// <param name="follower">follower 物件</param>
|
||||
/// <returns>HEX 編碼字串</returns>
|
||||
public string GenerateSearchKeywords(Model.follower follower)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 解密各欄位
|
||||
string phone_decrypted = string.IsNullOrEmpty(follower.phone) ? "" : DecryptAutoKey(follower.phone);
|
||||
string cellphone_decrypted = string.IsNullOrEmpty(follower.cellphone) ? "" : DecryptAutoKey(follower.cellphone);
|
||||
string id_code_decrypted = string.IsNullOrEmpty(follower.id_code) ? "" : DecryptAutoKey(follower.id_code);
|
||||
string passport_decrypted = string.IsNullOrEmpty(follower.passport) ? "" : DecryptAutoKey(follower.passport);
|
||||
|
||||
// 組合字串 (使用 | 分隔)
|
||||
string joinedString = string.Join("|", new string[] {
|
||||
phone_decrypted,
|
||||
cellphone_decrypted,
|
||||
id_code_decrypted,
|
||||
passport_decrypted
|
||||
});
|
||||
|
||||
// 轉換為 HEX 編碼
|
||||
if (string.IsNullOrEmpty(joinedString.Replace("|", "")))
|
||||
{
|
||||
return ""; // 如果所有欄位都是空的,返回空字串
|
||||
}
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(joinedString);
|
||||
string hexString = BitConverter.ToString(bytes).Replace("-", "").ToLower();
|
||||
return hexString;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return ""; // 發生錯誤時返回空字串
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 將搜尋字串轉換為 HEX 編碼 (用於搜尋功能)
|
||||
/// </summary>
|
||||
/// <param name="searchText">要搜尋的文字</param>
|
||||
/// <returns>HEX 編碼字串</returns>
|
||||
public string ConvertToHex(string searchText)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchText))
|
||||
return "";
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(searchText);
|
||||
string hexString = BitConverter.ToString(bytes).Replace("-", "").ToLower();
|
||||
return hexString;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user