From 2d1860637f076849948acfcb3159cf9faafeed47 Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期四, 29 八月 2024 16:36:43 +0800
Subject: [PATCH] 密码加密

---
 WebApi/Gs.Toolbox/UtilityHelper.cs  |   17 ++++++++
 WebApi/Gs.Toolbox/PasswordHelper.cs |   68 ++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/WebApi/Gs.Toolbox/PasswordHelper.cs b/WebApi/Gs.Toolbox/PasswordHelper.cs
new file mode 100644
index 0000000..f800b67
--- /dev/null
+++ b/WebApi/Gs.Toolbox/PasswordHelper.cs
@@ -0,0 +1,68 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gs.Toolbox
+{
+    public class PasswordHelper
+    {
+        #region  瀵嗙爜鍔犲瘑
+        /**/
+        /// <summary>  
+        /// 杞崐瑙掔殑鍑芥暟(DBC case)   
+        /// </summary>   
+        /// <param name="input">浠绘剰瀛楃涓�</param>   
+        /// <returns>鍗婅瀛楃涓�</returns>   
+        ///<remarks>   
+        ///鍏ㄨ绌烘牸涓�12288锛屽崐瑙掔┖鏍间负32   
+        ///鍏朵粬瀛楃鍗婅(33-126)涓庡叏瑙�(65281-65374)鐨勫搴斿叧绯绘槸锛氬潎鐩稿樊65248   
+        ///</remarks>   
+        private static string ToDBC(string input)
+        {
+            char[] c = input.ToCharArray();
+            for (int i = 0; i < c.Length; i++)
+            {
+                if (c[i] == 12288)
+                {
+                    c[i] = (char)32;
+                    continue;
+                }
+                if (c[i] > 65280 && c[i] < 65375)
+                    c[i] = (char)(c[i] - 65248);
+            }
+            return new string(c);
+        }
+
+        /// <summary>
+        /// 杞ぇ鍐�
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private static string ToUp(string input)
+        {
+            string s = ToDBC(input);
+            System.Text.StringBuilder sb = new StringBuilder();
+            char[] c = s.ToCharArray();
+            for (int i = 0; i < c.Length; i++)
+            {
+                sb.Append(c[i].ToString().ToUpper());
+            }
+            return sb.ToString();
+        }
+
+        /// <summary>
+        /// MD5鍔犲瘑
+        /// </summary>
+        /// <param name="strTxt"></param>
+        /// <returns></returns>
+        public static string ToMd5(string strTxt)
+        {
+            strTxt = ToUp(strTxt);
+            // return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strTxt, "MD5");
+            return strTxt;
+        }
+        #endregion
+    }
+}
diff --git a/WebApi/Gs.Toolbox/UtilityHelper.cs b/WebApi/Gs.Toolbox/UtilityHelper.cs
new file mode 100644
index 0000000..a0198de
--- /dev/null
+++ b/WebApi/Gs.Toolbox/UtilityHelper.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gs.Toolbox
+{
+    public static class UtilityHelper
+    {
+        public static Guid? GetGuid(string? str) {
+            if (string.IsNullOrEmpty(str))
+                return null;
+            return Guid.Parse(str);
+        }
+    }
+}

--
Gitblit v1.9.3