From 7203d5737085029b59281f5d390e175532dc1413 Mon Sep 17 00:00:00 2001 From: danial Date: Mon, 10 Nov 2025 17:59:37 +0800 Subject: [PATCH] Refactor variable names for clarity and consistency across multiple task files; update encryption methods to use Aes instead of RijndaelManaged. --- .claude/settings.local.json | 3 ++- .../AppleAccountChangeTask.cs | 2 +- .../CloseAuthenTask.cs | 2 +- AppleBatch_June.ExecuteTasks/EditAddrsTask.cs | 2 +- AppleBatch_June.ExecuteTasks/GameTask.cs | 2 +- .../OpenAuthenTask.cs | 2 +- .../QueryAuthBalanceTask.cs | 2 +- AppleBatch_June.ExecuteTasks/RecoveryTask.cs | 2 +- .../ShopBalanceTask.cs | 2 +- AppleBatch_June.Utils/APPLEHCHelp.cs | 2 +- AppleBatch_June.csproj | 1 + AppleBatch_June/DESEncrypt.cs | 20 ++++++---------- AppleBatch_June/FormLogin.cs | 2 +- AppleBatch_June/FromDBDataQuery.cs | 24 +++++++++---------- AppleBatch_June/FromMain.cs | 2 +- AppleBatch_June/Tools.cs | 6 ++--- DotNet.Utilities/HttpHelper.cs | 1 - 17 files changed, 36 insertions(+), 41 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 7f22bf2..71b3b33 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -2,7 +2,8 @@ "permissions": { "allow": [ "Bash(find:*)", - "Bash(dotnet build:*)" + "Bash(dotnet build:*)", + "Bash(dotnet publish:*)" ], "deny": [], "ask": [] diff --git a/AppleBatch_June.ExecuteTasks/AppleAccountChangeTask.cs b/AppleBatch_June.ExecuteTasks/AppleAccountChangeTask.cs index f43666c..1d6cdb1 100644 --- a/AppleBatch_June.ExecuteTasks/AppleAccountChangeTask.cs +++ b/AppleBatch_June.ExecuteTasks/AppleAccountChangeTask.cs @@ -83,7 +83,7 @@ namespace AppleBatch_June.ExecuteTasks { _action?.Invoke(guidTag, DisplyType.chongzhi, ""); string accountName = ""; - bool flag = false; + bool _flag = false; AppleChangeItem changeItem2 = new AppleChangeItem { newGuojia = changeItem.newGuojia, diff --git a/AppleBatch_June.ExecuteTasks/CloseAuthenTask.cs b/AppleBatch_June.ExecuteTasks/CloseAuthenTask.cs index eebfb69..32ebe2a 100644 --- a/AppleBatch_June.ExecuteTasks/CloseAuthenTask.cs +++ b/AppleBatch_June.ExecuteTasks/CloseAuthenTask.cs @@ -77,7 +77,7 @@ namespace AppleBatch_June.ExecuteTasks if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(14).consNum) { _action?.Invoke(guidTag, DisplyType.chongzhi, ""); - bool flag = false; + bool _flag = false; if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, null, this).RetrievePassword(openVpn, appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber) : new AppleiForgotWeb(openVpn, _action, null, this).RetrievePassword(appleAcount, newPassWord, guidTag, isCloseAuthen: true, ckTailNumber)) { APIUtlis.ApiApplyAct(14, "关闭双重认证"); diff --git a/AppleBatch_June.ExecuteTasks/EditAddrsTask.cs b/AppleBatch_June.ExecuteTasks/EditAddrsTask.cs index b90109a..87233aa 100644 --- a/AppleBatch_June.ExecuteTasks/EditAddrsTask.cs +++ b/AppleBatch_June.ExecuteTasks/EditAddrsTask.cs @@ -94,7 +94,7 @@ namespace AppleBatch_June.ExecuteTasks ckShippingAddress = ckShippingAddress }; string accountName = ""; - bool flag = false; + bool _flag = false; if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, _action, this).applyChangeAcount(appleAcount, changeItem, errorGoint: true, openVpn, guidTag, ref accountName) : new AppleManageWeb(openVpn, _action, _action, this).applyChangeAcount(appleAcount, changeItem, errorGoint: true, guidTag, ref accountName)) { sucessAct?.Invoke(guidTag); diff --git a/AppleBatch_June.ExecuteTasks/GameTask.cs b/AppleBatch_June.ExecuteTasks/GameTask.cs index 8f35e6a..b9a7c11 100644 --- a/AppleBatch_June.ExecuteTasks/GameTask.cs +++ b/AppleBatch_June.ExecuteTasks/GameTask.cs @@ -25,7 +25,7 @@ namespace AppleBatch_June.ExecuteTasks private int passGetGameByUrl(bool ckQueryMOdel, GetGameUtils itunes, string gameUrl, AppleItunesLogin itunesLogin) { - int num = 0; + int _num = 0; if (ckQueryMOdel) { return itunes.getNewGameByUrl3(gameUrl, itunesLogin); diff --git a/AppleBatch_June.ExecuteTasks/OpenAuthenTask.cs b/AppleBatch_June.ExecuteTasks/OpenAuthenTask.cs index 526f7d5..076920b 100644 --- a/AppleBatch_June.ExecuteTasks/OpenAuthenTask.cs +++ b/AppleBatch_June.ExecuteTasks/OpenAuthenTask.cs @@ -82,7 +82,7 @@ namespace AppleBatch_June.ExecuteTasks countryCode = countryCode, mode = mode }; - bool flag = false; + bool _flag = false; if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis(_action, null, this).OpenAuthen(appleAcount, new AppleChangeItem { countryCode = countryCode, diff --git a/AppleBatch_June.ExecuteTasks/QueryAuthBalanceTask.cs b/AppleBatch_June.ExecuteTasks/QueryAuthBalanceTask.cs index 5a5a8d4..617d852 100644 --- a/AppleBatch_June.ExecuteTasks/QueryAuthBalanceTask.cs +++ b/AppleBatch_June.ExecuteTasks/QueryAuthBalanceTask.cs @@ -77,7 +77,7 @@ namespace AppleBatch_June.ExecuteTasks if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(22).consNum) { _action?.Invoke(guidTag, DisplyType.chongzhi, ""); - bool flag = false; + bool _flag = false; if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis2(_action, null, this).applyQueryAuthBalance(appleAcount, openVpn, guidTag) : new ApplePrivacytWeb(openVpn, _action, null, this).applyQueryAuthBalance(appleAcount, guidTag)) { APIUtlis.ApiApplyAct(22, "密保查询余额"); diff --git a/AppleBatch_June.ExecuteTasks/RecoveryTask.cs b/AppleBatch_June.ExecuteTasks/RecoveryTask.cs index 42991fa..cffb6d1 100644 --- a/AppleBatch_June.ExecuteTasks/RecoveryTask.cs +++ b/AppleBatch_June.ExecuteTasks/RecoveryTask.cs @@ -78,7 +78,7 @@ namespace AppleBatch_June.ExecuteTasks if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(12).consNum) { _action?.Invoke(guidTag, DisplyType.chongzhi, ""); - bool flag = false; + bool _flag = false; if ((!(AppSysConfig.webProtocolS2k || checkApple)) ? new AppleManageWebUtlis(_action, null, this) { CheckAppleId = checkApple diff --git a/AppleBatch_June.ExecuteTasks/ShopBalanceTask.cs b/AppleBatch_June.ExecuteTasks/ShopBalanceTask.cs index 42516fc..4989261 100644 --- a/AppleBatch_June.ExecuteTasks/ShopBalanceTask.cs +++ b/AppleBatch_June.ExecuteTasks/ShopBalanceTask.cs @@ -76,7 +76,7 @@ namespace AppleBatch_June.ExecuteTasks if (((dynamic)obj)["Data"]["integral"] >= AppSysConfig.getTypeById(22).consNum) { _action?.Invoke(appleAcount.appleId, DisplyType.chongzhi, ""); - bool flag = false; + bool _flag = false; if ((!AppSysConfig.webProtocolS2k) ? new AppleManageWebUtlis2(_action, null, this).AppleQueryStoreBalance(appleAcount, openVpn) : new AppleShopWeb(openVpn, appleAcount.appleId, _action, null, this).AppleQueryStoreBalance(appleAcount, actGetCode)) { APIUtlis.ApiApplyAct(27, "商城余额查询"); diff --git a/AppleBatch_June.Utils/APPLEHCHelp.cs b/AppleBatch_June.Utils/APPLEHCHelp.cs index 9817ddb..14f0217 100644 --- a/AppleBatch_June.Utils/APPLEHCHelp.cs +++ b/AppleBatch_June.Utils/APPLEHCHelp.cs @@ -38,7 +38,7 @@ namespace AppleBatch_June.Utils array2[i] = (byte)palinData[i]; } int length = palinData.Length; - using (SHA1 sHA = new SHA1CryptoServiceProvider()) + using (SHA1 sHA = SHA1.Create()) { do { diff --git a/AppleBatch_June.csproj b/AppleBatch_June.csproj index c6f1913..93bfb45 100644 --- a/AppleBatch_June.csproj +++ b/AppleBatch_June.csproj @@ -9,6 +9,7 @@ True app.ico + false diff --git a/AppleBatch_June/DESEncrypt.cs b/AppleBatch_June/DESEncrypt.cs index dec8de0..ffc00f1 100644 --- a/AppleBatch_June/DESEncrypt.cs +++ b/AppleBatch_June/DESEncrypt.cs @@ -11,13 +11,7 @@ namespace AppleBatch_June byte[] bytes = Encoding.UTF8.GetBytes(key); byte[] bytes2 = Encoding.UTF8.GetBytes(iv); byte[] bytes3 = Encoding.UTF8.GetBytes(toEncrypt); - byte[] array = new RijndaelManaged - { - Key = bytes, - IV = bytes2, - Mode = CipherMode.CBC, - Padding = PaddingMode.Zeros - }.CreateEncryptor().TransformFinalBlock(bytes3, 0, bytes3.Length); + byte[] array = Aes.Create().CreateEncryptor(bytes, bytes2).TransformFinalBlock(bytes3, 0, bytes3.Length); return Convert.ToBase64String(array, 0, array.Length); } @@ -26,12 +20,12 @@ namespace AppleBatch_June byte[] bytes = Encoding.UTF8.GetBytes(key); byte[] bytes2 = Encoding.UTF8.GetBytes(iv); byte[] array = Convert.FromBase64String(toDecrypt); - using RijndaelManaged rijndaelManaged = new RijndaelManaged(); - rijndaelManaged.Key = bytes; - rijndaelManaged.IV = bytes2; - rijndaelManaged.Mode = CipherMode.CBC; - rijndaelManaged.Padding = PaddingMode.Zeros; - using ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(); + using Aes aes = Aes.Create(); + aes.Key = bytes; + aes.IV = bytes2; + aes.Mode = CipherMode.CBC; + aes.Padding = PaddingMode.Zeros; + using ICryptoTransform cryptoTransform = aes.CreateDecryptor(); byte[] bytes3 = cryptoTransform.TransformFinalBlock(array, 0, array.Length); return Encoding.UTF8.GetString(bytes3); } diff --git a/AppleBatch_June/FormLogin.cs b/AppleBatch_June/FormLogin.cs index 4ac5c35..db42b4d 100644 --- a/AppleBatch_June/FormLogin.cs +++ b/AppleBatch_June/FormLogin.cs @@ -73,7 +73,7 @@ namespace AppleBatch_June } ServicePointManager.DefaultConnectionLimit = 512; ServicePointManager.Expect100Continue = false; - ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true; try { diff --git a/AppleBatch_June/FromDBDataQuery.cs b/AppleBatch_June/FromDBDataQuery.cs index 41d21b6..a81d68a 100644 --- a/AppleBatch_June/FromDBDataQuery.cs +++ b/AppleBatch_June/FromDBDataQuery.cs @@ -310,12 +310,12 @@ namespace AppleBatch_June } } } - using RijndaelManaged rijndaelManaged = new RijndaelManaged(); - rijndaelManaged.Key = array2[0]; - rijndaelManaged.IV = array2[1]; - rijndaelManaged.Mode = CipherMode.CBC; - rijndaelManaged.Padding = PaddingMode.Zeros; - using ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(); + using Aes aes = Aes.Create(); + aes.Key = array2[0]; + aes.IV = array2[1]; + aes.Mode = CipherMode.CBC; + aes.Padding = PaddingMode.Zeros; + using ICryptoTransform cryptoTransform = aes.CreateDecryptor(); byte[] byList = cryptoTransform.TransformFinalBlock(array3, 0, array3.Length); Array.Clear(array2[0], 0, array2[0].Length); Array.Clear(array2[1], 0, array2[1].Length); @@ -330,12 +330,12 @@ namespace AppleBatch_June public byte[] Decrypt(byte[] toEncryptArray, byte[] keyArray, byte[] ivArray) { - using RijndaelManaged rijndaelManaged = new RijndaelManaged(); - rijndaelManaged.Key = keyArray; - rijndaelManaged.IV = ivArray; - rijndaelManaged.Mode = CipherMode.CBC; - rijndaelManaged.Padding = PaddingMode.Zeros; - using ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(); + using Aes aes = Aes.Create(); + aes.Key = keyArray; + aes.IV = ivArray; + aes.Mode = CipherMode.CBC; + aes.Padding = PaddingMode.Zeros; + using ICryptoTransform cryptoTransform = aes.CreateDecryptor(); return cryptoTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); } diff --git a/AppleBatch_June/FromMain.cs b/AppleBatch_June/FromMain.cs index 64cd321..73362d7 100644 --- a/AppleBatch_June/FromMain.cs +++ b/AppleBatch_June/FromMain.cs @@ -1582,7 +1582,7 @@ namespace AppleBatch_June comLoadAccounts.MouseWheel += ComLoadAccounts_MouseWheel; ThreadPool.SetMinThreads(Tools.getTaskSize(openVpn: true, 1000) * 2, 5); Text = Text + " 当前版本:" + FormLogin.versions; - ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true; foreach (TabPage tabPage in tabControl1.TabPages) { diff --git a/AppleBatch_June/Tools.cs b/AppleBatch_June/Tools.cs index 86e14e1..148b8e2 100644 --- a/AppleBatch_June/Tools.cs +++ b/AppleBatch_June/Tools.cs @@ -611,14 +611,14 @@ namespace AppleBatch_June public static DateTime GetTimeByTimeStamp(long unixTimeStamp) { - return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(unixTimeStamp); + return TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local).AddSeconds(unixTimeStamp); } public static DateTime GetTimeByJsTimeStamp(long unixTimeStamp) { try { - return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(unixTimeStamp); + return TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local).AddMilliseconds(unixTimeStamp); } catch (Exception) { @@ -814,7 +814,7 @@ namespace AppleBatch_June public static string EncodeBase64(byte[] source) { - string text = ""; + string _text = ""; try { return Convert.ToBase64String(source); diff --git a/DotNet.Utilities/HttpHelper.cs b/DotNet.Utilities/HttpHelper.cs index c346427..34f2ee6 100644 --- a/DotNet.Utilities/HttpHelper.cs +++ b/DotNet.Utilities/HttpHelper.cs @@ -487,7 +487,6 @@ namespace DotNet.Utilities private byte[] GetByte() { - byte[] array = null; using MemoryStream memoryStream = new MemoryStream(); if (response.ContentEncoding != null && response.ContentEncoding.Equals("gzip", StringComparison.InvariantCultureIgnoreCase)) {