using AllBase; using AllBase.Helper; using TemuKJD.BaseForms; using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; using Work; using Work.Api; namespace TemuKJD.KJDForms.ToolForms { public partial class ProxyForm : LRBaseForm { public ProxyForm() { InitializeComponent(); MaximizeBox = false; } private void proxyButtonX_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtProxy.Text)) return; string sAgentIpKey = this.txtProxy.Text.ParseToString().Trim(); InitProxyIp(sAgentIpKey); try { FileBase.WriteAllText("temp/proxy.txt", sAgentIpKey, Encoding.UTF8); } catch { } if (!string.IsNullOrEmpty(GetProxyHtml.txtUrl)) { BaseMsgForm.ShowInfo("设置成功", "", FormLevel.SMALL); return; } } private void ProxyForm_Load(object sender, EventArgs e) { if (BaseClass.Ico != null) Icon = BaseClass.Ico; if (FileBase.Exists("temp/proxy.txt")) { string sAgentIpKey = FileBase.ReadAllText("temp/proxy.txt").Trim(); InitProxyIp(sAgentIpKey); txtProxy.Text = sAgentIpKey; } } public static void InitProxyIp(string sAgentIpKey, bool isShowErrorWindow = true) { string sOrderId = DESDecode(sAgentIpKey, GlobalConfig.cAgentIpCode); if (string.IsNullOrEmpty(sOrderId)) { if (isShowErrorWindow) BaseMsgForm.ShowError("代理秘钥验证不通过,请检查秘钥!"); return; } string sProxyUrl = "http://bjn.66daili.cn/API/bjn/get/?orderid=" + sOrderId + "&token=5AF433ED506FA475"; GetProxyHtml.txtUrl = sProxyUrl; GetProxyHtml.orderId = sOrderId; } private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; public static string DESDecode(string source, string sKey) { try { byte[] inputByteArray = System.Convert.FromBase64String(source);//Encoding.UTF8.GetBytes(source); using (DESCryptoServiceProvider des = new DESCryptoServiceProvider()) { des.Key = ASCIIEncoding.ASCII.GetBytes(sKey); des.IV = Keys; System.IO.MemoryStream ms = new System.IO.MemoryStream(); using (CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write)) { cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); cs.Close(); } string str = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); return str; } } catch (Exception ex) { return ""; } } private void btnAgentIPUrl_Click(object sender, EventArgs e) { GetHtml.OpenUrl("http://guangsu.deifei.com.cn/"); } } }