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; } } } }