Bladeren bron

Merge branch 'main' of http://139.155.244.27:822/LSR/gouhuo

DESKTOP-5BUCSUT\LSR 1 jaar geleden
bovenliggende
commit
68dfa38045

+ 2 - 2
SFGgouhuo/Assets/Bundles/UI/Prefab/Dlg/ES/ESLanguage.prefab

@@ -224,7 +224,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &8659688983455605753
 RectTransform:
   m_ObjectHideFlags: 0
@@ -732,7 +732,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 0
+  m_IsActive: 1
 --- !u!224 &5554496079357600200
 RectTransform:
   m_ObjectHideFlags: 0

+ 27 - 27
SFGgouhuo/Assets/Bundles/UI/Prefab/FaceBuildPanel.prefab

@@ -58,14 +58,14 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.40392157}
+  m_Color: {r: 1, g: 1, b: 1, a: 0.31764707}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_Sprite: {fileID: 21300000, guid: 3ea8e0c8b0ad1a548bf66bf7e6c6bcc7, type: 3}
+  m_Sprite: {fileID: 21300000, guid: e905925fe2e827e4aa902d3e0abf5805, type: 3}
   m_Type: 0
   m_PreserveAspect: 0
   m_FillCenter: 1
@@ -475,7 +475,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 434.3, y: -68.118805}
+  m_AnchoredPosition: {x: 408.2, y: -67.6}
   m_SizeDelta: {x: 412, y: 56}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &1179904542601660722
@@ -1346,8 +1346,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 4.854889, y: 0}
-  m_SizeDelta: {x: -9.7098, y: 0}
+  m_AnchoredPosition: {x: 15.4, y: -1.1}
+  m_SizeDelta: {x: -53.4615, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &6670287506845167124
 CanvasRenderer:
@@ -1377,7 +1377,7 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_text: "\u8EAB \u4F53 \u7279 \u5F81"
+  m_text: "\u8EAB\u4F53\u7279\u5F81"
   m_isRightToLeft: 0
   m_fontAsset: {fileID: 11400000, guid: 18cb8b8d5310b5d49ae0ec1b446a2110, type: 2}
   m_sharedMaterial: {fileID: -8851797225679313563, guid: 18cb8b8d5310b5d49ae0ec1b446a2110, type: 2}
@@ -1414,7 +1414,7 @@ MonoBehaviour:
   m_HorizontalAlignment: 2
   m_VerticalAlignment: 512
   m_textAlignment: 65535
-  m_characterSpacing: 0
+  m_characterSpacing: 20
   m_wordSpacing: 0
   m_lineSpacing: 0
   m_lineSpacingMax: 0
@@ -1874,10 +1874,10 @@ RectTransform:
   m_Father: {fileID: 7201276217817588878}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 1, y: 1}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 0}
+  m_SizeDelta: {x: 200, y: 46}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &3066529537014836464
 CanvasRenderer:
@@ -1907,8 +1907,8 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_Sprite: {fileID: -8876641551535793593, guid: 0ac2686669301174d86d7c52b16ea75b, type: 3}
-  m_Type: 1
+  m_Sprite: {fileID: 21300000, guid: 00f3c03deca37614ca0fe38b8e71fe15, type: 3}
+  m_Type: 0
   m_PreserveAspect: 0
   m_FillCenter: 1
   m_FillMethod: 4
@@ -2214,7 +2214,7 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_text: "\u670D \u88C5 \u914D \u9970"
+  m_text: "\u670D\u88C5\u914D\u9970"
   m_isRightToLeft: 0
   m_fontAsset: {fileID: 11400000, guid: 18cb8b8d5310b5d49ae0ec1b446a2110, type: 2}
   m_sharedMaterial: {fileID: -8851797225679313563, guid: 18cb8b8d5310b5d49ae0ec1b446a2110, type: 2}
@@ -2251,7 +2251,7 @@ MonoBehaviour:
   m_HorizontalAlignment: 2
   m_VerticalAlignment: 512
   m_textAlignment: 65535
-  m_characterSpacing: 0
+  m_characterSpacing: 20
   m_wordSpacing: 0
   m_lineSpacing: 0
   m_lineSpacingMax: 0
@@ -2614,10 +2614,10 @@ RectTransform:
   m_Father: {fileID: 3306285130158083725}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 0}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
+  m_AnchoredPosition: {x: 13.5, y: 0}
+  m_SizeDelta: {x: 200, y: 46}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &6016005527000836344
 CanvasRenderer:
@@ -2647,8 +2647,8 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_Sprite: {fileID: -8876641551535793593, guid: 0ac2686669301174d86d7c52b16ea75b, type: 3}
-  m_Type: 1
+  m_Sprite: {fileID: 21300000, guid: 00f3c03deca37614ca0fe38b8e71fe15, type: 3}
+  m_Type: 0
   m_PreserveAspect: 0
   m_FillCenter: 1
   m_FillMethod: 4
@@ -3367,7 +3367,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
-  m_AnchoredPosition: {x: 0.54083, y: 294}
+  m_AnchoredPosition: {x: -10.6, y: 300.5}
   m_SizeDelta: {x: 735.71, y: 47.944}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &982010693170706198
@@ -3473,7 +3473,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
-  m_AnchoredPosition: {x: 0, y: 479}
+  m_AnchoredPosition: {x: 10.2, y: 476.1}
   m_SizeDelta: {x: 384, y: 56}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &4998572468752533409
@@ -4642,7 +4642,7 @@ MonoBehaviour:
   onValueChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_IsOn: 1
+  m_IsOn: 0
 --- !u!1 &7576626126584662780
 GameObject:
   m_ObjectHideFlags: 0
@@ -4680,7 +4680,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0.5, y: 0}
   m_AnchorMax: {x: 0.5, y: 1}
-  m_AnchoredPosition: {x: -87.11305, y: 0.25491905}
+  m_AnchoredPosition: {x: -100.59, y: 0.25494}
   m_SizeDelta: {x: 201.1854, y: -10.283901}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &6300118966906744338
@@ -4768,7 +4768,7 @@ MonoBehaviour:
   onValueChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_IsOn: 0
+  m_IsOn: 1
 --- !u!1 &8220997245496499820
 GameObject:
   m_ObjectHideFlags: 0
@@ -5158,11 +5158,11 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 1435332481416965747, guid: 863e1ebc08b38c349a82f38db225ed29, type: 3}
       propertyPath: m_AnchoredPosition.x
-      value: 759.9
+      value: 810.6
       objectReference: {fileID: 0}
     - target: {fileID: 1435332481416965747, guid: 863e1ebc08b38c349a82f38db225ed29, type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: 477.3
+      value: 482.1
       objectReference: {fileID: 0}
     - target: {fileID: 1435332481416965747, guid: 863e1ebc08b38c349a82f38db225ed29, type: 3}
       propertyPath: m_LocalEulerAnglesHint.x

BIN
SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/Subtract (7).png


+ 13 - 1
SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/我的形象UI.png.meta → SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/Subtract (7).png.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 3ea8e0c8b0ad1a548bf66bf7e6c6bcc7
+guid: 00f3c03deca37614ca0fe38b8e71fe15
 TextureImporter:
   internalIDToNameTable: []
   externalObjects: {}
@@ -100,6 +100,18 @@ TextureImporter:
     overridden: 0
     androidETC2FallbackOverride: 0
     forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Android
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
   spriteSheet:
     serializedVersion: 2
     sprites: []

BIN
SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/我的形象UI (1).png


+ 133 - 0
SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/我的形象UI (1).png.meta

@@ -0,0 +1,133 @@
+fileFormatVersion: 2
+guid: e905925fe2e827e4aa902d3e0abf5805
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 12
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 0
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  vTOnly: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: 1
+    aniso: 1
+    mipBias: 0
+    wrapU: 1
+    wrapV: 1
+    wrapW: 0
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 1
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  flipbookRows: 1
+  flipbookColumns: 1
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  ignorePngGamma: 0
+  applyGammaDecoding: 0
+  cookieLightType: 0
+  platformSettings:
+  - serializedVersion: 3
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Standalone
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: WebGL
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Android
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 5e97eb03825dee720800000000000000
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
SFGgouhuo/Assets/GameResources/UI/Image/FaceBuild/我的形象UI.png


+ 113 - 9
SFGgouhuo/Assets/Scripts/UI/Loading/DlgLogin.cs

@@ -1,8 +1,12 @@
-using LitJson;
+using AR.Core;
+using LitJson;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.NetworkInformation;
 using TMPro;
 using UnityEngine;
 using UnityEngine.Networking;
@@ -14,7 +18,9 @@ namespace Assets
     {
         public TMP_InputField inputField;
         public Button confirmBtn;
-        UserData userData;
+        WhiteList whiteList;
+
+        string url = "http://172.18.10.189:8000/swagger/index.html";
         public override void OnCloseWindow()
         {
 
@@ -27,18 +33,21 @@ namespace Assets
         public override void OnInitWindow()
         {
             LoadJson();
+            GetMacAddress();
             confirmBtn.onClick.AddListener(async () =>
             {
-                if (userData.table.Contains(inputField.text))
+                
+
+                if (whiteList.table.Contains(inputField.text))
                 {
-                    UIManager.Instance.HideUI(WindowID.DlgLogin);
-                    await UIManager.Instance.ShowUI(WindowID.FaceBuildPanel);
+                    StartCoroutine(GetSecretKey());
+
+
                 }
                 else
                 {
                     await UIManager.Instance.ShowUI(WindowID.DlgLoginFaild);
                 }
-
             });
         }
 
@@ -46,17 +55,112 @@ namespace Assets
         {
 
         }
+        IEnumerator GetSecretKey()
+        {
+            string url = "http://172.18.10.189:8000/api/Account/SecretKey";
+            AccountMsg accountMsg = new AccountMsg();
+            accountMsg.Account = inputField.text;
+            string json = JsonMapper.ToJson(accountMsg);
+            byte[] postBytes = System.Text.Encoding.Default.GetBytes(json);
+            UnityWebRequest request = UnityWebRequest.Post(url, UnityWebRequest.kHttpVerbPOST);
+            request.uploadHandler =new UploadHandlerRaw(postBytes);
+            request.SetRequestHeader("Content-Type", "application/json");
+            request.timeout = 5;
+            yield return request.SendWebRequest();
+            if (request.result == UnityWebRequest.Result.Success)
+            {
+                Debug.Log(request.downloadHandler.text);
+                GetSecretKeyResult result = JsonMapper.ToObject<GetSecretKeyResult>(request.downloadHandler.text);
+                StartCoroutine(Login(result.message));
+            }
+            else
+            {
+                Debug.Log(request.error);
+            }
+        }
+        IEnumerator Login(string secretKey)
+        {
+            string url = "http://172.18.10.189:8000/api/Account/Login";
+            Userdata userInfo = new Userdata();
+            userInfo.account = inputField.text;
+            userInfo.mac = DesEncryptHelper.Encrypt(GetMacAddress(), secretKey);
+            string json = JsonMapper.ToJson(userInfo);
+            byte[] postBytes = System.Text.Encoding.Default.GetBytes(json);
+
+            UnityWebRequest request = UnityWebRequest.Post(url, UnityWebRequest.kHttpVerbPOST);
+            request.uploadHandler = new UploadHandlerRaw(postBytes);
+            request.SetRequestHeader("Content-Type", "application/json");
+            request.timeout = 5;
+            yield return request.SendWebRequest();
+            if (request.result == UnityWebRequest.Result.Success)
+            {
+                Debug.Log(request.downloadHandler.text);
+                UIManager.Instance.HideUI(WindowID.DlgLogin);
+                UIManager.Instance.ShowUI(WindowID.FaceBuildPanel);
+            }
+            else
+            {
+                Debug.Log(request.error);
+            }
+        }
+
+        private string GetMacAddress()
+        {
+            string physicalAddress = "";
 
+            NetworkInterface[] nice = NetworkInterface.GetAllNetworkInterfaces();
+
+            foreach (NetworkInterface adaper in nice)
+            {
+                if (adaper.Description == "en0")
+                {
+                    physicalAddress = adaper.GetPhysicalAddress().ToString();
+                    break;
+                }
+                else
+                {
+                    physicalAddress = adaper.GetPhysicalAddress().ToString();
+
+                    if (physicalAddress != "")
+                    {
+                        break;
+                    };
+                }
+            }
+            return physicalAddress;
+        }
         public async void LoadJson()
         {
 
             var txtAsset = await YooAssetManager.Instance.LoadAsset<TextAsset>("Assets/Bundles/Config/WhiteList");
-            userData = JsonMapper.ToObject<UserData>(txtAsset.text);
+            whiteList = JsonMapper.ToObject<WhiteList>(txtAsset.text);
         }
+    }
+    /// <summary>
+    /// 账号和Mac地址
+    /// </summary>
+    class Userdata
+    {
+        public string account;
+        public string mac;
+    }
+    /// <summary>
+    /// 输入账号
+    /// </summary>
+    class AccountMsg
+    {
+        public string Account;
+    }
 
+    struct GetSecretKeyResult
+    {
+        public int code;
+        public string message;
+        public string data;
     }
-    class UserData
+
+    class WhiteList
     {
-        public List<string> table;
+        public string[] table;
     }
 }

+ 113 - 0
SFGgouhuo/Assets/Scripts/UI/Tools/DesEncryptHelper.cs

@@ -0,0 +1,113 @@
+using SM.Core;
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace AR.Core
+{
+    ///<summary>Des加密</summary>
+    public class DesEncryptHelper
+    {
+        private const string Key = "W1#x!3Cm";
+
+        /// <summary>
+        /// DES+Base64加密
+        /// <para>采用ECB、PKCS7</para>
+        /// </summary>
+        /// <param name="encryptString">加密字符串</param>
+        /// <param name="key">秘钥</param>
+        public static string Encrypt(string encryptString, string key = null)
+        {
+            return Encrypt(encryptString, key, false, true);
+        }
+
+        /// <summary>
+        /// DES+Base64解密
+        /// <para>采用ECB、PKCS7</para>
+        /// </summary>
+        /// <param name="decryptString">解密字符串</param>
+        /// <param name="key">秘钥</param>
+        public static string Decrypt(string decryptString, string key = null)
+        {
+            return Decrypt(decryptString, key, false);
+        }
+
+        /// <summary>
+        /// DES+16进制加密
+        /// <para>采用ECB、PKCS7</para>
+        /// </summary>
+        /// <param name="encryptString">加密字符串</param>
+        /// <param name="key">秘钥</param>
+        /// <param name="lowerCase">是否小写</param>
+        public static string Encrypt4Hex(string encryptString, string key = null, bool lowerCase = false)
+        {
+            return Encrypt(encryptString, key, true, lowerCase);
+        }
+
+        /// <summary>
+        /// DES+16进制解密
+        /// <para>采用ECB、PKCS7</para>
+        /// </summary>
+        /// <param name="decryptString">解密字符串</param>
+        /// <param name="key">秘钥</param>
+        public static string Decrypt4Hex(string decryptString, string key = null)
+        {
+            return Decrypt(decryptString, key, true);
+        }
+
+        /// <summary>DES加密</summary>
+        private static string Encrypt(string encryptString, string key, bool hex, bool lowerCase = false)
+        {
+            if (string.IsNullOrEmpty(encryptString))
+                return null;
+            if (string.IsNullOrEmpty(key))
+                key = Key;
+            if (key.Length < 8)
+                throw new ArgumentException("秘钥长度为8位", nameof(key));
+
+            var keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8));
+            var inputByteArray = Encoding.UTF8.GetBytes(encryptString);
+            DES des = DES.Create();
+            des.Mode = CipherMode.ECB;
+            des.Key = keyBytes;
+            des.Padding = PaddingMode.PKCS7;
+
+            using (var stream = new MemoryStream())
+            {
+                var cStream = new CryptoStream(stream, des.CreateEncryptor(), CryptoStreamMode.Write);
+                cStream.Write(inputByteArray, 0, inputByteArray.Length);
+                cStream.FlushFinalBlock();
+
+                var bytes = stream.ToArray();
+                return hex ? bytes.ToHex(lowerCase) : bytes.ToBase64();
+            }
+        }
+
+        /// <summary>DES解密</summary>
+        private static string Decrypt(string decryptString, string key, bool hex)
+        {
+            if (string.IsNullOrEmpty(decryptString))
+                return null;
+            if (string.IsNullOrEmpty(key))
+                key = Key;
+            if (key.Length < 8)
+                throw new ArgumentException("秘钥长度为8位", nameof(key));
+
+            var keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8));
+            var inputByteArray = hex ? decryptString.HexToBytes() : Convert.FromBase64String(decryptString);
+            DES des = DES.Create();
+            des.Mode = CipherMode.ECB;
+            des.Key = keyBytes;
+            des.Padding = PaddingMode.PKCS7;
+
+            using (var mStream = new MemoryStream())
+            {
+                var cStream = new CryptoStream(mStream, des.CreateDecryptor(), CryptoStreamMode.Write);
+                cStream.Write(inputByteArray, 0, inputByteArray.Length);
+                cStream.FlushFinalBlock();
+                return Encoding.UTF8.GetString(mStream.ToArray());
+            }
+        }
+    }
+}

+ 11 - 0
SFGgouhuo/Assets/Scripts/UI/Tools/DesEncryptHelper.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9c245057d8e40b14798238cea5be2ab8
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 205 - 0
SFGgouhuo/Assets/Scripts/UI/Tools/UtilConvertExtensions.cs

@@ -0,0 +1,205 @@
+using System;
+using System.Text;
+
+namespace SM.Core
+{
+    public static class UtilConvertExtensions
+    {
+
+        public static int ToInt(this object thisValue)
+        {
+            int reval = 0;
+            if (thisValue == null) return 0;
+            if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return reval;
+        }
+
+        public static int ToInt(this object thisValue, int errorValue)
+        {
+            int reval;
+            if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static long ToLong(this object s)
+        {
+            if (s == null || s == DBNull.Value)
+                return 0L;
+
+            long.TryParse(s.ToString(), out long result);
+            return result;
+        }
+
+        public static double ToMoney(this object thisValue)
+        {
+            double reval;
+            if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return 0;
+        }
+
+        public static double ToMoney(this object thisValue, double errorValue)
+        {
+            double reval;
+            if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static string ToString(this object thisValue)
+        {
+            if (thisValue != null) return thisValue.ToString().Trim();
+            return "";
+        }
+
+        public static string ToString(this object thisValue, string errorValue)
+        {
+            if (thisValue != null) return thisValue.ToString().Trim();
+            return errorValue;
+        }
+
+        /// <summary>转换成Double/Single</summary>
+        /// <param name="s"></param>
+        /// <param name="digits">小数位数</param>
+        public static double ToDouble(this object s, int? digits = null)
+        {
+            if (s == null || s == DBNull.Value)
+                return 0d;
+
+            double.TryParse(s.ToString(), out double result);
+
+            if (digits == null)
+                return result;
+
+            return Math.Round(result, digits.Value);
+        }
+
+        public static decimal ToDecimal(this object thisValue)
+        {
+            decimal reval;
+            if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return 0;
+        }
+
+        public static decimal ToDecimal(this object thisValue, decimal errorValue)
+        {
+            decimal reval;
+            if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static DateTime ToDateTime(this object thisValue)
+        {
+            DateTime reval = DateTime.MinValue;
+            if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
+            {
+                reval = Convert.ToDateTime(thisValue);
+            }
+            return reval;
+        }
+
+        public static DateTime ToDateTime(this object thisValue, DateTime errorValue)
+        {
+            DateTime reval;
+            if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static bool ToBool(this object thisValue)
+        {
+            bool reval = false;
+            if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return reval;
+        }
+
+        public static byte ToByte(this object s)
+        {
+            if (s == null || s == DBNull.Value)
+                return 0;
+
+            byte.TryParse(s.ToString(), out byte result);
+            return result;
+        }
+
+        #region ==字节转换==
+        /// <summary>转换为16进制</summary>
+        /// <param name="bytes"></param>
+        /// <param name="lowerCase">是否小写</param>
+        public static string ToHex(this byte[] bytes, bool lowerCase = true)
+        {
+            if (bytes == null)
+                return null;
+
+            var result = new StringBuilder();
+            var format = lowerCase ? "x2" : "X2";
+            for (var i = 0; i < bytes.Length; i++)
+            {
+                result.Append(bytes[i].ToString(format));
+            }
+
+            return result.ToString();
+        }
+
+        /// <summary>16进制转字节数组</summary>
+        /// <param name="s"></param>
+        public static byte[] HexToBytes(this string s)
+        {
+            if (s==null)
+                return null;
+            var bytes = new byte[s.Length / 2];
+
+            for (int x = 0; x < s.Length / 2; x++)
+            {
+                int i = (Convert.ToInt32(s.Substring(x * 2, 2), 16));
+                bytes[x] = (byte)i;
+            }
+
+            return bytes;
+        }
+
+        /// <summary>转换为Base64</summary>
+        /// <param name="bytes"></param>
+        public static string ToBase64(this byte[] bytes)
+        {
+            if (bytes == null)
+                return null;
+
+            return Convert.ToBase64String(bytes);
+        }
+
+        public static byte[] ToByteArray(this string str)
+        {
+            byte[] byteArray = Encoding.Default.GetBytes(str);
+            return byteArray;
+        }
+
+        public static string ToJson(this object obj)
+        {
+            return LitJson.JsonMapper.ToJson(obj);
+        }
+
+        #endregion
+    }
+}

+ 11 - 0
SFGgouhuo/Assets/Scripts/UI/Tools/UtilConvertExtensions.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3c59a503222e3624eaaa5bff91023f1e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: