From 4d2df5b7058a760de1b18d1c32bbbf5763f8e136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= <hevinci@hotmail.com>
Date: Thu, 13 Mar 2025 16:29:48 +0800
Subject: [PATCH] Update TestBundleEncryption.cs

---
 .../TestBundleEncryption.cs                        | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Assets/YooAsset/Samples~/Test Sample/Runtime/T2_TestBuldinFileSystem/TestBundleEncryption.cs b/Assets/YooAsset/Samples~/Test Sample/Runtime/T2_TestBuldinFileSystem/TestBundleEncryption.cs
index b82160cd..1cb38960 100644
--- a/Assets/YooAsset/Samples~/Test Sample/Runtime/T2_TestBuldinFileSystem/TestBundleEncryption.cs	
+++ b/Assets/YooAsset/Samples~/Test Sample/Runtime/T2_TestBuldinFileSystem/TestBundleEncryption.cs	
@@ -3,9 +3,6 @@ using System.IO;
 using System.Text;
 using System.Collections;
 using UnityEngine;
-using UnityEngine.UI;
-using UnityEngine.U2D;
-using UnityEngine.TestTools;
 using NUnit.Framework;
 using YooAsset;
 
@@ -231,6 +228,7 @@ public class WebFileStreamDecryption : IWebDecryptionServices
 {
     public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
     {
+        /*
         byte[] copyData = new byte[fileInfo.FileData.Length];
         Buffer.BlockCopy(fileInfo.FileData, 0, copyData, 0, fileInfo.FileData.Length);
 
@@ -242,5 +240,15 @@ public class WebFileStreamDecryption : IWebDecryptionServices
         WebDecryptResult decryptResult = new WebDecryptResult();
         decryptResult.Result = AssetBundle.LoadFromMemory(copyData);
         return decryptResult;
+        */
+
+        for (int i = 0; i < fileInfo.FileData.Length; i++)
+        {
+            fileInfo.FileData[i] ^= BundleStream.KEY;
+        }
+
+        WebDecryptResult decryptResult = new WebDecryptResult();
+        decryptResult.Result = AssetBundle.LoadFromMemory(fileInfo.FileData);
+        return decryptResult;
     }
 }
\ No newline at end of file