34 lines
966 B
C#
34 lines
966 B
C#
|
using System;
|
||
|
using System.IO;
|
||
|
using YooAsset;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 文件偏移加密方式
|
||
|
/// </summary>
|
||
|
public class FileOffsetEncryption : IEncryptionServices
|
||
|
{
|
||
|
int offset = 254;
|
||
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||
|
{
|
||
|
// 注意:只对音频资源包加密
|
||
|
//if (fileInfo.BundleName.Contains("_gameres_audio"))
|
||
|
//{
|
||
|
|
||
|
byte[] fileData = File.ReadAllBytes(fileInfo.FileLoadPath);
|
||
|
var encryptedData = new byte[fileData.Length + offset];
|
||
|
Buffer.BlockCopy(fileData, 0, encryptedData, offset, fileData.Length);
|
||
|
|
||
|
EncryptResult result = new EncryptResult();
|
||
|
result.Encrypted = true;
|
||
|
result.EncryptedData = encryptedData;
|
||
|
return result;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// EncryptResult result = new EncryptResult();
|
||
|
// result.Encrypted = false;
|
||
|
// return result;
|
||
|
//}
|
||
|
}
|
||
|
}
|