guodong 1 жил өмнө
parent
commit
05b596c519

+ 35 - 0
GameClient/Assets/YooAsset/Editor/GFGAsset/Extension/FileOffsetEncryption.cs

@@ -0,0 +1,35 @@
+using System;
+using System.IO;
+using UnityEngine;
+
+namespace YooAsset
+{
+    // 文件偏移加密方式的示例代码
+    public class FileOffsetEncryption : IEncryptionServices
+    {
+        public EncryptResult Encrypt(EncryptFileInfo fileInfo)
+        {
+            if (fileInfo.BundleName.Contains("dressup")
+                || fileInfo.BundleName.Contains("dll")
+                || fileInfo.BundleName.Contains("card"))
+            {
+                Debug.Log($"Encrypt {fileInfo.BundleName}");
+                int offset = 30;
+                byte[] fileData = File.ReadAllBytes(fileInfo.FilePath);
+                var encryptedData = new byte[fileData.Length + offset];
+                Buffer.BlockCopy(fileData, 0, encryptedData, offset, fileData.Length);
+
+                EncryptResult result = new EncryptResult();
+                result.LoadMethod = EBundleLoadMethod.LoadFromFileOffset;
+                result.EncryptedData = encryptedData;
+                return result;
+            }
+            else
+            {
+                EncryptResult result = new EncryptResult();
+                result.LoadMethod = EBundleLoadMethod.Normal;
+                return result;
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/YooAsset/Editor/GFGAsset/Extension/FileOffsetEncryption.cs.meta

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

+ 29 - 0
GameClient/Assets/YooAsset/Runtime/GFG/GameDecryptionServices.cs

@@ -0,0 +1,29 @@
+using System.IO;
+
+namespace YooAsset
+{
+    public class GameDecryptionServices : IDecryptionServices
+    {
+        public ulong LoadFromFileOffset(DecryptFileInfo fileInfo)
+        {
+            return 30;
+        }
+
+        public byte[] LoadFromMemory(DecryptFileInfo fileInfo)
+        {
+            // 如果没有内存加密方式,可以返回空
+            throw null;
+        }
+
+        public Stream LoadFromStream(DecryptFileInfo fileInfo)
+        {
+            // 如果没有流加密方式,可以返回空
+            throw null;
+        }
+
+        public uint GetManagedReadBufferSize()
+        {
+            return 1024;
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/YooAsset/Runtime/GFG/GameDecryptionServices.cs.meta

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