parse.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. using System.Text;
  2. using dodohold.core;
  3. using System.Text.RegularExpressions;
  4. using System.Net;
  5. using System.Linq;
  6. using System.Security.Cryptography;
  7. using TencentCloud.Ecm.V20190719.Models;
  8. using System.Diagnostics;
  9. using static dodohold.core.ZTOExpress.CreateOrderArgs;
  10. namespace molilian.core
  11. {
  12. public partial class AlimamaPlus
  13. {
  14. private string _accountName;
  15. private int _accountId;
  16. private string _company;
  17. private string _tb_token;
  18. private string _floorId;
  19. private string _refpid;
  20. private string _user_agent;
  21. private string _cookies;
  22. private WebProxy? _proxy = null;
  23. private string _api;
  24. private int _api_id = 0;
  25. public TkConfigDTO _config;
  26. private static string _end_point;
  27. private static TkPoolDTO _account;
  28. static Random _random = new Random();
  29. public static string _url_pattern = @"https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
  30. static AlimamaPlus()
  31. {
  32. _end_point = Environment.GetEnvironmentVariable("EndPoint");
  33. }
  34. public AlimamaPlus(TkPoolDTO account)
  35. {
  36. // string accountName, string tb_token, string floorId, string refpid,
  37. // string cookies, string user_agent, string nodeName
  38. _config = TkConfigCore.Get();
  39. _account = account;
  40. _accountId = account.id;
  41. _accountName = account.name;
  42. _company = account.company;
  43. _tb_token = account.tb_token;
  44. _floorId = account.floorId;
  45. _refpid = account.refpid;
  46. _cookies = account.cookies;
  47. _user_agent = account.user_agent;
  48. if (!string.IsNullOrEmpty(account.nodeName))
  49. {
  50. _proxy = ProxyNodesCore.GetOne(account.nodeName);
  51. }
  52. _api = account.api;
  53. _api_id = account.api_id;
  54. }
  55. public bool ShouldIgnoreOtherAff(string content)
  56. {
  57. TkDataDTO result = new();
  58. //(_, _, var link_type, _) = InternalTextProcessing(content, ref result);
  59. InternalTextProcessing(content, ref result);
  60. return result.link_type == LinkTypeEnum.other_aff;
  61. }
  62. public TkDataDTO UnionParse(string content, ref TkDataDTO result)
  63. {
  64. InternalTextProcessing(content, ref result);
  65. //(result.success, result.content, result.link_type, result.shortLinkurl) = InternalTextProcessing(content,ref result);
  66. if (result.link_type == LinkTypeEnum.other_aff)
  67. {
  68. result.channel = TkChannelEnum.tb;
  69. result.channel_type = ChannelTypeEnum.tb;
  70. result.link_type = LinkTypeEnum.unknown;
  71. result.success = false;
  72. result.message = "放弃转链";
  73. result.reason = "其他推广链接";
  74. result.subCode = TkSubCodeEnum.OtherPromo;
  75. result.accountName = string.Empty;
  76. result.content = content;
  77. //result.deeplink_url = GetDeeplink(null);
  78. result.itemName = GetTitle(content);
  79. }
  80. else
  81. {
  82. //处理过后的正文 用于转链
  83. if (result.success) content = result.content;
  84. result = alimamaParse(content, result);
  85. }
  86. result.content = content;
  87. result.link_type = result.link_type;
  88. return result;
  89. }
  90. public async Task<TkDataDTO> UnionParseAsync(string content, TkDataDTO result,
  91. CancellationToken cancellationToken = default,
  92. Dictionary<string, long> swData = null)
  93. {
  94. result.itemName = "点击打开淘宝APP";
  95. result = await InternalTextProcessingAsync(content, result, cancellationToken, swData);
  96. if (result.link_type == LinkTypeEnum.other_aff)
  97. {
  98. //============================== 其他推广链接 ==============================
  99. result.channel = TkChannelEnum.tb;
  100. result.channel_type = ChannelTypeEnum.tb;
  101. result.link_type = LinkTypeEnum.other_aff;
  102. result.success = false;
  103. result.message = "放弃转链";
  104. result.reason = "其他推广链接";
  105. result.subCode = TkSubCodeEnum.OtherPromo;
  106. result.accountName = string.Empty;
  107. result.content = content;
  108. //result.deeplink_url = GetDeeplink(null);
  109. //result.itemName = GetTitle(content);
  110. return result;
  111. }
  112. //处理过后的正文 用于转链
  113. if (!result.success)
  114. {
  115. switch (result.link_type)
  116. {
  117. case LinkTypeEnum.profile:
  118. case LinkTypeEnum.live:
  119. case LinkTypeEnum.video:
  120. case LinkTypeEnum.note:
  121. case LinkTypeEnum.goods:
  122. case LinkTypeEnum.baseDomain:
  123. result.reason = string.Empty;
  124. break;
  125. default:
  126. result.reason = "非标准链接";
  127. result.subCode = TkSubCodeEnum.NonStdLink;
  128. return result;
  129. }
  130. }
  131. //============================== 放弃转链-地区过滤 ==============================
  132. bool is_ignore2 = FlowControlIgnoreRequest(out string reason);
  133. if (is_ignore2)
  134. {
  135. result.success = false;
  136. result.message = "放弃转链";
  137. result.reason = reason;
  138. result.subCode = TkSubCodeEnum.TrafficCtrl;
  139. return result;
  140. }
  141. result = await alimamaParseAsync(result.content, result, cancellationToken);
  142. if (!result.success)
  143. {
  144. result.itemName = "点击打开淘宝APP";
  145. }
  146. if (string.IsNullOrEmpty(result.itemName) || result.link_type == LinkTypeEnum.profile)
  147. {
  148. result.itemName = "点击打开淘宝APP";
  149. }
  150. return result;
  151. }
  152. public static string ReplaceUrls(string content, string shortLink)
  153. {
  154. if (string.IsNullOrEmpty(content) || string.IsNullOrEmpty(shortLink)) return content;
  155. string result = content;
  156. Regex regex = new(_url_pattern);
  157. MatchCollection matches = regex.Matches(content);
  158. foreach (Match m in matches.Cast<Match>())
  159. {
  160. string url = m.Value;
  161. if (url.Contains("https://s.tb.cn/") ||
  162. url.Contains("http://s.tb.cn/") ||
  163. url.Contains("http://m.tb.cn/") ||
  164. url.Contains("http://m.tb.cn/") ||
  165. url.Contains("http://e.tb.cn/") ||
  166. url.Contains("https://e.tb.cn/"))
  167. {
  168. result = result.Replace(url, shortLink);
  169. }
  170. }
  171. return result;
  172. }
  173. public static string RemoveUrls(string content)
  174. {
  175. if (string.IsNullOrEmpty(content)) return content;
  176. string result = content;
  177. Regex regex = new(_url_pattern);
  178. MatchCollection matches = regex.Matches(content);
  179. foreach (Match m in matches.Cast<Match>())
  180. {
  181. string url = m.Value;
  182. result = result.Replace(url, string.Empty);
  183. }
  184. return result;
  185. }
  186. public static string GetLink(string content)
  187. {
  188. if (string.IsNullOrEmpty(content)) return content;
  189. //string pattern = @"https?:\/\/?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?(\?[\S]+)?";
  190. Regex regex = new(_url_pattern);
  191. MatchCollection matches = regex.Matches(content);
  192. string result = string.Empty;
  193. if (matches.Count > 0)
  194. {
  195. result = matches[^1].Value; // 返回第一个匹配到的 URL
  196. }
  197. result = result.Replace("&nbsp;", "");
  198. if (result.StartsWith("http://e.tb.cn/")) result = result.Replace("http://", "https://");
  199. return result;
  200. }
  201. public static string GetTaobaoLink(string content)
  202. {
  203. if (string.IsNullOrEmpty(content)) return content;
  204. string result = content;
  205. string pattern = @"(https?://(?:[\w-]+\.)*(?:tb\.cn|taobao\.com|juhuasuan\.com|tmall\.com|tmall\.hk)(?:/[a-zA-Z0-9\-\._~:/?#[\]@!$&'()*+,;=%]*)?)";
  206. Regex regex = new(pattern, RegexOptions.IgnoreCase);
  207. MatchCollection matches = regex.Matches(content);
  208. if (matches.Count > 0)
  209. {
  210. return matches[^1].Value; // 返回第一个匹配到的 URL
  211. }
  212. return string.Empty;
  213. }
  214. public static string GetDeeplink(string url)
  215. {
  216. if (string.IsNullOrEmpty(url)) return "tbopen://m.taobao.com/tbopen/index.html";
  217. string result = $"tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&h5Url={url.UrlEncode()}";
  218. //string result = $"tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&bootImage=0&afcPromotionOpen=false&bc_fl_src=h5_huanduan&source=slk_dp&h5Url={url.UrlEncode()}";
  219. return result;
  220. }
  221. public static string GetTitle(string content)
  222. {
  223. if (string.IsNullOrEmpty(content)) return string.Empty;
  224. string url = GetLink(content);
  225. if (!string.IsNullOrEmpty(url)) content = content.Replace(url, string.Empty);
  226. content = content.Replace("点击链接直接打开 或者 淘宝搜索直接打开", string.Empty).Trim();
  227. string[] words = Regex.Split(content, @"\s+");
  228. string word = words[^1];
  229. word = word.TrimStart('「').TrimEnd('」');
  230. return word;
  231. }
  232. public static bool IgnoreRegionIncluded(string _ignoreRegions, string? ipInfo, out string regionInfo)
  233. {
  234. regionInfo = string.Empty;
  235. if (string.IsNullOrEmpty(_ignoreRegions) || string.IsNullOrEmpty(ipInfo)) return false;
  236. string[] parts = ipInfo.Split('|');
  237. string countryInfo = null;
  238. if (parts.Length >= 4)
  239. {
  240. countryInfo = parts[0];
  241. regionInfo = parts[3];
  242. }
  243. if (string.IsNullOrEmpty(regionInfo)) return false;
  244. if (string.IsNullOrEmpty(countryInfo)) return false;
  245. string[] ignoreRegions = _ignoreRegions.Split('|');
  246. if (ignoreRegions.Contains(regionInfo)) return true;
  247. if (ignoreRegions.Contains(countryInfo))
  248. {
  249. regionInfo = countryInfo;
  250. return true;
  251. }
  252. foreach (var region in ignoreRegions)
  253. {
  254. if ("海外".Equals(region) && !"中国".Equals(countryInfo) && !"0".Equals(countryInfo))
  255. {
  256. regionInfo = "海外";
  257. return true;
  258. }
  259. }
  260. return false;
  261. }
  262. public static async Task<bool> OtherPlatformAsync(string content)
  263. {
  264. try
  265. {
  266. //腾讯会议
  267. string wemeetId = await ToolParsePlus.GetWemeetIdAsync(content);
  268. if (!string.IsNullOrEmpty(wemeetId)) return true;
  269. //百度网盘
  270. string surl = string.Empty, pwd = string.Empty;
  271. _ = ToolParsePlus.GetPanLink(content, ref surl, ref pwd);
  272. if (!string.IsNullOrEmpty(surl)) return true;
  273. //JD
  274. string url = JdUnionPlus.GetLink(content);
  275. var urlType = JdUnionPlus.GetLinkType(url, out _, out _);
  276. if (urlType != LinkTypeEnum.unknown) return true;
  277. //DY
  278. url = DyUnionPlus.GetLink(content);
  279. urlType = DyUnionPlus.GetLinkType(content, url);
  280. if (urlType != LinkTypeEnum.unknown) return true;
  281. }
  282. catch { }
  283. return false;
  284. }
  285. public static bool MatchRegexes(string text, List<string> extended)
  286. {
  287. text = RemoveUrls(text);
  288. string special_symbols = $"\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲";
  289. string[] base_patterns =
  290. [
  291. $@"(.*?\d{{2}}\s[a-zA-Z]{{2}}\d{{4}}\s.*?[{special_symbols}]+[a-zA-Z0-9\s]+[{special_symbols}]).*",
  292. $@"[{special_symbols}]+\s*([a-zA-Z]{{1,2}}\d{{2,4}}\s[a-zA-Z0-9]{{11}}|[a-zA-Z0-9]{{11}}[a-zA-Z]{{1,2}}\d{{2,4}}\s|[a-zA-Z0-9]{{11}})\s*[{special_symbols}]+",
  293. @"🍑♭ɑ◑下单|Tao宝"
  294. ];
  295. List<string> mergedArray = extended.Union(base_patterns).ToList();
  296. /*
  297. (.*?\\d{2}\\s[a-zA-Z]{2}\\d{4}\\s.*?[\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲]+[a-zA-Z0-9\\s]+[\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲])).*\n[\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲]+\\s*([a-zA-Z]{1,2}\\d{2,4}\\s[a-zA-Z0-9]{11}|[a-zA-Z0-9]{11}[a-zA-Z]{1,2}\\d{2,4}\\s|[a-zA-Z0-9]{11})\\s*[\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲]+\n🍑♭ɑ◑下单|Tao宝
  298. 【3瓶】恩威万蓝莓叶黄素酯软糖儿童成人上班族如酸涩肿胀可服用,<z5TYWAblvTw >:// HU7709,打開/
  299. 置顶小助手,方便下次查询\r\n1★【劵】无\r\n2★【返.佣】 0.29圆 \r\n3★【付款.价】24.9 圆\r\n \r\n 1 ¢HZv5WAboi0D¢(/:/ HU8866\r\
  300. n长按覆制本内容,打开TaoBao/\r\n-\r\n返佣是指商家的推广佣.金\r\n通过我回复的口令下単收货后,我
  301. 会微信红.苞返给你!!\r\n\r\n有疑问可回复“人工”咨询客服*/
  302. //🍑🔗上 水和肌精华水& CZ0 VWdCWC2gj97&,
  303. //6฿04ZDWzrwxjN)/ CA97
  304. //1😘 腹制这条(CZ00 iHvtWzrXa7O(:/
  305. //¥EC8DG4Zj0dhd8DOw¥MF6563 oIo0WzOF1Cp##X-PyVpHiPlyj1OP##
  306. //6.6₵vU2jWzIW3Qx₲/ CZ5224
  307. //$F56nWzIDSFZ$
  308. //0復製这条口令( CZ00 D0M4WzI0jFJ¢,📱咑開[Tao宝]就可下单:/
  309. //8fuzhi本条消息:¤ CZ3458 JSR1WzrPCBU¤,打开🍑♭ɑ◑下单/
  310. //5€Lz6SWzrkLDw¥:// CZ13
  311. //3₲Igq3Wzkc5np₳:// CZ15
  312. //9.9🎈【康师傅易拉罐6罐】口伶:6₰TnxKWzr0wff₪:// CZ69
  313. //4₲99Y0WzJdK6S₳:// CZ46
  314. //4fuzhi本条消息:¤ CZ0002 WVCSWzrk6Ix¤,打开🍑♭ɑ◑下单/
  315. bool anyMatch = false;
  316. foreach (string pattern in mergedArray)
  317. {
  318. if (Regex.IsMatch(text, pattern, RegexOptions.IgnoreCase))
  319. {
  320. anyMatch = true;
  321. }
  322. }
  323. return anyMatch;
  324. }
  325. public static bool MatchOtherInfo(string text, List<string> extended)
  326. {
  327. string[] base_patterns =
  328. [
  329. "[ďȌƯƔɪƝɖƟɏƖԂȎȗϓɫɧơȲǏđǫƲƳɨǹƊȮǚƴɬɲƿȖȳɳɗʮϔӢǙɦɒɎƥʘưΊƞǪȈʠΌǓϒίȠƠƱƗǸþŌŬÿĩŅÞÓũŸÎŎûįŇĎÖÙŷÏňÜÝÍñĎÒüŶľńĎ0ųŷÏŇdǒǔyí℡抖yí℡ÞŐûŷÌñ]{6}",
  330. @"(?:.+)极速版(?:口令|搜索)",
  331. @"##[a-zA-Z0-9]+##\[抖音(?:极速版)?(?:口令|搜索)\]",
  332. @"岽|亰|菄|京东|婛",
  333. "打开【剪映】",
  334. "weishi://|baiduhaokan://",
  335. "复制打开「UC浏览器」|UC瀏覽器",
  336. "番茄免费小说",
  337. @"\?chanTag=[^&\s]*口令",
  338. @"(https?://pan\.baidu\.com/s/[A-Za-z0-9?\-_=]+)",
  339. @"https?:\/\/meeting\.tencent\.com[^\s]*",
  340. @"#腾讯会议:(\d{3}-\d{3}-\d{3})"
  341. ];
  342. List<string> mergedArray = extended.Union(base_patterns).ToList();
  343. bool anyMatch = false;
  344. foreach (string pattern in mergedArray)
  345. {
  346. if (Regex.IsMatch(text, pattern, RegexOptions.IgnoreCase))
  347. {
  348. anyMatch = true;
  349. }
  350. }
  351. return anyMatch;
  352. }
  353. public static bool MatchMultiToken(string text, List<string> extended)
  354. {
  355. text = RemoveUrls(text);
  356. string special_symbols = $"\\$\\(\\)\\/\\#\\&\\<\\>฿¢¥¥$🗝₰₵₲¤₪₴€₤£₳《¢💰🔑🎵✔💲🔐📲";
  357. string[] base_patterns =
  358. [
  359. @"[!$¥%]+([a-zA-Z0-9]{16})[!$¥%]+",
  360. @"\^v(\d+#[a-zA-Z0-9]+)(?:\?.*)?\^",
  361. "##([a-zA-Z0-9\\-]+)##",
  362. $@"(.*?\d{{2}}\s[a-zA-Z]{{2}}\d{{4}}\s.*?[{special_symbols}]+[a-zA-Z0-9\s]+[{special_symbols}]).*",
  363. $@"[{special_symbols}]+\s*([a-zA-Z]{{1,2}}\d{{2,4}}\s[a-zA-Z0-9]{{11}}|[a-zA-Z0-9]{{11}}[a-zA-Z]{{1,2}}\d{{2,4}}\s|[a-zA-Z0-9]{{11}})\s*[{special_symbols}]+",
  364. ];
  365. // PAGE6:/^v130091#P2J6EDxN8p8?chanTag=d9dc522bdea27437514052ea50f6a787^
  366. List<string> mergedArray = extended.Union(base_patterns).ToList();
  367. int matchCount = 0;
  368. foreach (string pattern in mergedArray)
  369. {
  370. Match match = Regex.Match(text, pattern, RegexOptions.IgnoreCase);
  371. if (match.Success)
  372. {
  373. matchCount++;
  374. text = text.Replace(match.Groups[^1].Value, ""); // 移除匹配的部分文本
  375. }
  376. }
  377. return matchCount >= 2;
  378. }
  379. public static bool FilterRiskLink(string ip, string oaid, string content, out string reason)
  380. {
  381. reason = string.Empty;
  382. string itemId = ExtractItemId(content);
  383. if (string.IsNullOrEmpty(itemId)) return false;
  384. string cacheKey = $":cache:parse:{ip}_{oaid}_{itemId}";
  385. int flag = RedisHelper.Get<int>(cacheKey);
  386. if (flag > 0)
  387. {
  388. reason = $"口令用户";
  389. return true;
  390. }
  391. return false;
  392. }
  393. public static bool ShouldIgnoreRequest(string ip, string oaid, out string reason)
  394. {
  395. reason = string.Empty;
  396. try
  397. {
  398. // IP和流量控制
  399. var config = TkConfigCore.Get();
  400. string ignorePercentageCity = config.ignorePercentageCity;
  401. string? ipInfo = IP2RegionPlus.Search(ip);
  402. if (IgnoreRegionIncluded(ignorePercentageCity, ipInfo, out string regionInfo))
  403. {
  404. reason = $"地区控制:{regionInfo}";
  405. return true;
  406. }
  407. if (TkLogCore.InBlacklist(config.blacklist_oaid, oaid))
  408. {
  409. reason = "OAID黑名单";
  410. return true;
  411. }
  412. int limit_num = config.tk_limit_per_ip_24h;
  413. if (limit_num > 0)
  414. {
  415. int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.tb, ip);
  416. if (num >= limit_num)
  417. {
  418. reason = "IP控制";
  419. return true;
  420. }
  421. }
  422. limit_num = config.tk_limit_per_oaid_24h;
  423. if (limit_num > 0)
  424. {
  425. int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.tb, oaid);
  426. if (num >= limit_num)
  427. {
  428. reason = "OAID控制";
  429. return true;
  430. }
  431. }
  432. }
  433. catch (Exception ex)
  434. {
  435. reason = "配置异常";
  436. }
  437. return false;
  438. }
  439. public static bool FlowControlIgnoreRequest(out string reason)
  440. {
  441. reason = string.Empty;
  442. try
  443. {
  444. // IP和流量控制
  445. var config = TkConfigCore.Get();
  446. int ignorePercentage = config.ignorePercentage;
  447. if (ignorePercentage == 0) return false;
  448. var randomValue = (decimal)_random.Next(0, 100);
  449. bool result = randomValue <= ignorePercentage; // 如果生成的随机数小于忽略百分比,则返回 true,表示需要忽略请求
  450. if (result)
  451. {
  452. reason = "流量控制";
  453. return true;
  454. }
  455. }
  456. catch (Exception ex)
  457. {
  458. reason = $"配置异常";
  459. }
  460. return false;
  461. }
  462. public static TkDataDTO GetFormattedObject(string content, string ip, string oaid)
  463. {
  464. string shortLinkurl = GetTaobaoLink(content);
  465. string deeplink_url = GetDeeplink(shortLinkurl);
  466. return new TkDataDTO()
  467. {
  468. message = string.Empty,
  469. subCode = TkSubCodeEnum.Other,
  470. channel = TkChannelEnum.tb,
  471. accountName = string.Empty,
  472. success = false,
  473. content = content,
  474. link_type = LinkTypeEnum.unknown,
  475. ip = ip,
  476. oaid = oaid,
  477. couponAmount = 0,
  478. taoToken = string.Empty,
  479. elapsedTime = 0,
  480. itemName = "点击打开淘宝APP",
  481. shortLinkurl = shortLinkurl,
  482. deeplink_url = deeplink_url,
  483. create_time = DateTime.Now,
  484. end_point = _end_point,
  485. };
  486. }
  487. public static string OppoDecode(string content)
  488. {
  489. try
  490. {
  491. string secretKey = "BwFeIvOEDZy9MFGi0JLZBO4yEhR44DGV";
  492. byte[] keyBytes = Encoding.UTF8.GetBytes(secretKey);
  493. if (!content.Contains("%IV%")) return content;
  494. string cipherText = content.GetContentPart("", "%IV%");
  495. string ivText = content.GetContentPart("%IV%", "");
  496. byte[] cipherBytes = Convert.FromBase64String(cipherText);
  497. byte[] ivBytes = Convert.FromBase64String(ivText);
  498. using RijndaelManaged aes = new();
  499. aes.Key = keyBytes;
  500. aes.IV = ivBytes;
  501. aes.Mode = CipherMode.CFB;
  502. aes.Padding = PaddingMode.PKCS7;
  503. ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
  504. var outBytes = decryptor.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length);
  505. content = outBytes.ConvertToString();
  506. }
  507. catch (Exception e) { }
  508. return content;
  509. }
  510. }
  511. }