原生文件加密/解密

This commit is contained in:
unknown
2024-07-27 18:37:17 +08:00
parent 07d34891ef
commit c6377ce544
7 changed files with 95 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System.Text;
namespace YooAsset
{
@@ -316,9 +317,19 @@ namespace YooAsset
{
if (Exists(bundle) == false)
return null;
string filePath = GetCacheFileLoadPath(bundle);
return FileUtility.ReadAllBytes(filePath);
var data = FileUtility.ReadAllBytes(filePath);
if (bundle.Encrypted)
{
if (DecryptionServices == null)
{
YooLogger.Error($"DecryptionServices is Null!");
return null;
}
return DecryptionServices.ReadFileData(data);
}
return data;
}
public virtual string ReadFileText(PackageBundle bundle)
{
@@ -326,7 +337,18 @@ namespace YooAsset
return null;
string filePath = GetCacheFileLoadPath(bundle);
return FileUtility.ReadAllText(filePath);
var data = FileUtility.ReadAllBytes(filePath);
if (bundle.Encrypted)
{
if (DecryptionServices == null)
{
YooLogger.Error($"DecryptionServices is Null!");
return null;
}
data = DecryptionServices.ReadFileData(data);
}
return Encoding.UTF8.GetString(data);
}
#region