From 314d964e48eaee6e6b0c1c4822ce6e36331808af Mon Sep 17 00:00:00 2001 From: wisdomwei201804 Date: Tue, 26 Jun 2018 13:48:08 +0800 Subject: [PATCH] =?UTF-8?q?v3.8.4.0=20=201=E3=80=81=E5=A2=9E=E5=8A=A0Ngrok?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=822=E3=80=81=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=80=92=E8=AE=A1=E6=97=B6=E6=8E=A7=E4=BB=B6=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=80=92=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E8=B6=85=E8=BF=873=E4=BD=8D=E6=97=B6=E8=A2=AB=E9=81=AE?= =?UTF-8?q?=E6=8C=A1=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=823=E3=80=81?= =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net.nutcore.aliddns/EncryptHelper.cs | 161 ++++++++++++ .../net.nutcore.aliddns/Form_main.Designer.cs | 6 +- .../net.nutcore.aliddns/Form_main.cs | 158 ------------ .../Properties/AssemblyInfo.cs | 4 +- .../net.nutcore.aliddns.csproj | 9 +- .../net.nutcore.aliddns/updateinfo.txt | 3 + .../net.nutcore.aliddns/yml.cs | 244 ------------------ 7 files changed, 175 insertions(+), 410 deletions(-) create mode 100644 net.nutcore.aliddns/net.nutcore.aliddns/EncryptHelper.cs delete mode 100644 net.nutcore.aliddns/net.nutcore.aliddns/yml.cs diff --git a/net.nutcore.aliddns/net.nutcore.aliddns/EncryptHelper.cs b/net.nutcore.aliddns/net.nutcore.aliddns/EncryptHelper.cs new file mode 100644 index 0000000..2a9a63a --- /dev/null +++ b/net.nutcore.aliddns/net.nutcore.aliddns/EncryptHelper.cs @@ -0,0 +1,161 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace net.nutcore.aliddns +{ + /// + /// 加密工具类 + /// + public class EncryptHelper + { + //默认密钥 + private static string AESKey = "[45/*YUIdse..e;]"; + private static string DESKey = "[&HdN72]"; + + /// + /// AES加密 + /// + public static string AESEncrypt(string value, string _aeskey = null) + { + if (string.IsNullOrEmpty(_aeskey)) + { + _aeskey = AESKey; + } + + byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); + byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); + + RijndaelManaged rDel = new RijndaelManaged(); + rDel.Key = keyArray; + rDel.Mode = CipherMode.ECB; + rDel.Padding = PaddingMode.PKCS7; + + ICryptoTransform cTransform = rDel.CreateEncryptor(); + byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); + + return Convert.ToBase64String(resultArray, 0, resultArray.Length); + } + + /// + /// AES解密 + /// + public static string AESDecrypt(string value, string _aeskey = null) + { + try + { + if (string.IsNullOrEmpty(_aeskey)) + { + _aeskey = AESKey; + } + byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); + byte[] toEncryptArray = Convert.FromBase64String(value); + + RijndaelManaged rDel = new RijndaelManaged(); + rDel.Key = keyArray; + rDel.Mode = CipherMode.ECB; + rDel.Padding = PaddingMode.PKCS7; + + ICryptoTransform cTransform = rDel.CreateDecryptor(); + byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); + + return Encoding.UTF8.GetString(resultArray); + } + catch + { + return string.Empty; + } + } + + /// + /// DES加密 + /// + public static string DESEncrypt(string value, string _deskey = null) + { + if (string.IsNullOrEmpty(_deskey)) + { + _deskey = DESKey; + } + + byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); + byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); + + DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); + rDel.Key = keyArray; + rDel.Mode = CipherMode.ECB; + rDel.Padding = PaddingMode.PKCS7; + + ICryptoTransform cTransform = rDel.CreateEncryptor(); + byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); + + return Convert.ToBase64String(resultArray, 0, resultArray.Length); + } + + /// + /// DES解密 + /// + public static string DESDecrypt(string value, string _deskey = null) + { + try + { + if (string.IsNullOrEmpty(_deskey)) + { + _deskey = DESKey; + } + byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); + byte[] toEncryptArray = Convert.FromBase64String(value); + + DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); + rDel.Key = keyArray; + rDel.Mode = CipherMode.ECB; + rDel.Padding = PaddingMode.PKCS7; + + ICryptoTransform cTransform = rDel.CreateDecryptor(); + byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); + + return Encoding.UTF8.GetString(resultArray); + } + catch + { + return string.Empty; + } + } + + public static string MD5(string value) + { + byte[] result = Encoding.UTF8.GetBytes(value); + MD5 md5 = new MD5CryptoServiceProvider(); + byte[] output = md5.ComputeHash(result); + return BitConverter.ToString(output).Replace("-", ""); + } + + public static string HMACMD5(string value, string hmacKey) + { + HMACSHA1 hmacsha1 = new HMACSHA1(Encoding.UTF8.GetBytes(hmacKey)); + byte[] result = System.Text.Encoding.UTF8.GetBytes(value); + byte[] output = hmacsha1.ComputeHash(result); + + + return BitConverter.ToString(output).Replace("-", ""); + } + + /// + /// base64编码 + /// + /// + public static string Base64Encode(string value) + { + string result = Convert.ToBase64String(Encoding.Default.GetBytes(value)); + return result; + } + /// + /// base64解码 + /// + /// + public static string Base64Decode(string value) + { + string result = Encoding.Default.GetString(Convert.FromBase64String(value)); + return result; + } + } +} diff --git a/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.Designer.cs b/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.Designer.cs index 2c8c1e3..a84e46f 100644 --- a/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.Designer.cs +++ b/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.Designer.cs @@ -189,13 +189,13 @@ // // label_nextUpdateSeconds // - this.label_nextUpdateSeconds.AutoSize = true; this.label_nextUpdateSeconds.ForeColor = System.Drawing.Color.Red; - this.label_nextUpdateSeconds.Location = new System.Drawing.Point(97, 99); + this.label_nextUpdateSeconds.Location = new System.Drawing.Point(87, 99); this.label_nextUpdateSeconds.Name = "label_nextUpdateSeconds"; - this.label_nextUpdateSeconds.Size = new System.Drawing.Size(17, 12); + this.label_nextUpdateSeconds.Size = new System.Drawing.Size(30, 12); this.label_nextUpdateSeconds.TabIndex = 3; this.label_nextUpdateSeconds.Text = "60"; + this.label_nextUpdateSeconds.TextAlign = System.Drawing.ContentAlignment.TopRight; // // updateNow // diff --git a/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.cs b/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.cs index fb89161..69c0971 100644 --- a/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.cs +++ b/net.nutcore.aliddns/net.nutcore.aliddns/Form_main.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; -using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -914,161 +913,4 @@ namespace net.nutcore.aliddns } } } - - /// - /// 加密工具类 - /// - public class EncryptHelper - { - //默认密钥 - private static string AESKey = "[45/*YUIdse..e;]"; - private static string DESKey = "[&HdN72]"; - - /// - /// AES加密 - /// - public static string AESEncrypt(string value, string _aeskey = null) - { - if (string.IsNullOrEmpty(_aeskey)) - { - _aeskey = AESKey; - } - - byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); - byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); - - RijndaelManaged rDel = new RijndaelManaged(); - rDel.Key = keyArray; - rDel.Mode = CipherMode.ECB; - rDel.Padding = PaddingMode.PKCS7; - - ICryptoTransform cTransform = rDel.CreateEncryptor(); - byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - - return Convert.ToBase64String(resultArray, 0, resultArray.Length); - } - - /// - /// AES解密 - /// - public static string AESDecrypt(string value, string _aeskey = null) - { - try - { - if (string.IsNullOrEmpty(_aeskey)) - { - _aeskey = AESKey; - } - byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); - byte[] toEncryptArray = Convert.FromBase64String(value); - - RijndaelManaged rDel = new RijndaelManaged(); - rDel.Key = keyArray; - rDel.Mode = CipherMode.ECB; - rDel.Padding = PaddingMode.PKCS7; - - ICryptoTransform cTransform = rDel.CreateDecryptor(); - byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - - return Encoding.UTF8.GetString(resultArray); - } - catch - { - return string.Empty; - } - } - - /// - /// DES加密 - /// - public static string DESEncrypt(string value, string _deskey = null) - { - if (string.IsNullOrEmpty(_deskey)) - { - _deskey = DESKey; - } - - byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); - byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); - - DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); - rDel.Key = keyArray; - rDel.Mode = CipherMode.ECB; - rDel.Padding = PaddingMode.PKCS7; - - ICryptoTransform cTransform = rDel.CreateEncryptor(); - byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - - return Convert.ToBase64String(resultArray, 0, resultArray.Length); - } - - /// - /// DES解密 - /// - public static string DESDecrypt(string value, string _deskey = null) - { - try - { - if (string.IsNullOrEmpty(_deskey)) - { - _deskey = DESKey; - } - byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); - byte[] toEncryptArray = Convert.FromBase64String(value); - - DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); - rDel.Key = keyArray; - rDel.Mode = CipherMode.ECB; - rDel.Padding = PaddingMode.PKCS7; - - ICryptoTransform cTransform = rDel.CreateDecryptor(); - byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - - return Encoding.UTF8.GetString(resultArray); - } - catch - { - return string.Empty; - } - } - - public static string MD5(string value) - { - byte[] result = Encoding.UTF8.GetBytes(value); - MD5 md5 = new MD5CryptoServiceProvider(); - byte[] output = md5.ComputeHash(result); - return BitConverter.ToString(output).Replace("-", ""); - } - - public static string HMACMD5(string value, string hmacKey) - { - HMACSHA1 hmacsha1 = new HMACSHA1(Encoding.UTF8.GetBytes(hmacKey)); - byte[] result = System.Text.Encoding.UTF8.GetBytes(value); - byte[] output = hmacsha1.ComputeHash(result); - - - return BitConverter.ToString(output).Replace("-", ""); - } - - /// - /// base64编码 - /// - /// - public static string Base64Encode(string value) - { - string result = Convert.ToBase64String(Encoding.Default.GetBytes(value)); - return result; - } - /// - /// base64解码 - /// - /// - public static string Base64Decode(string value) - { - string result = Encoding.Default.GetString(Convert.FromBase64String(value)); - return result; - } - - - } } diff --git a/net.nutcore.aliddns/net.nutcore.aliddns/Properties/AssemblyInfo.cs b/net.nutcore.aliddns/net.nutcore.aliddns/Properties/AssemblyInfo.cs index a360133..a82c5b6 100644 --- a/net.nutcore.aliddns/net.nutcore.aliddns/Properties/AssemblyInfo.cs +++ b/net.nutcore.aliddns/net.nutcore.aliddns/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.8.3.5")] -[assembly: AssemblyFileVersion("3.8.3.5")] +[assembly: AssemblyVersion("3.8.4.0")] +[assembly: AssemblyFileVersion("3.8.4.0")] diff --git a/net.nutcore.aliddns/net.nutcore.aliddns/net.nutcore.aliddns.csproj b/net.nutcore.aliddns/net.nutcore.aliddns/net.nutcore.aliddns.csproj index e5014ab..a91879d 100644 --- a/net.nutcore.aliddns/net.nutcore.aliddns/net.nutcore.aliddns.csproj +++ b/net.nutcore.aliddns/net.nutcore.aliddns/net.nutcore.aliddns.csproj @@ -88,6 +88,7 @@ + Form @@ -109,7 +110,6 @@ - Form_About.cs @@ -149,7 +149,9 @@ - + + PreserveNewest + @@ -172,7 +174,8 @@ - copy "$(SolutionDir)net.nutcore.aliddns\updateinfo.txt" "$(TargetDir)" + +