mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update ResourceModule.Services.cs
This commit is contained in:
@@ -212,14 +212,9 @@ namespace TEngine
|
|||||||
byte[] decryptedData = new byte[fileInfo.FileData.Length];
|
byte[] decryptedData = new byte[fileInfo.FileData.Length];
|
||||||
Buffer.BlockCopy(fileInfo.FileData, 0, decryptedData, 0, fileInfo.FileData.Length);
|
Buffer.BlockCopy(fileInfo.FileData, 0, decryptedData, 0, fileInfo.FileData.Length);
|
||||||
|
|
||||||
// 批量异或解密(性能优化)
|
for (int i = 0; i < decryptedData.Length; i++)
|
||||||
int batchSize = sizeof(ulong);
|
|
||||||
int length = decryptedData.Length / batchSize * batchSize;
|
|
||||||
for (int i = 0; i < length; i += batchSize)
|
|
||||||
{
|
{
|
||||||
ulong value = BitConverter.ToUInt64(decryptedData, i);
|
decryptedData[i] ^= BundleStream.KEY;
|
||||||
value ^= BundleStream.KEY;
|
|
||||||
Buffer.BlockCopy(BitConverter.GetBytes(value), 0, decryptedData, i, batchSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebDecryptResult decryptResult = new WebDecryptResult();
|
WebDecryptResult decryptResult = new WebDecryptResult();
|
||||||
@@ -249,16 +244,10 @@ public class BundleStream : FileStream
|
|||||||
public override int Read(byte[] array, int offset, int count)
|
public override int Read(byte[] array, int offset, int count)
|
||||||
{
|
{
|
||||||
var index = base.Read(array, offset, count);
|
var index = base.Read(array, offset, count);
|
||||||
// 批量异或解密(性能优化)
|
for (int i = 0; i < array.Length; i++)
|
||||||
int batchSize = sizeof(ulong);
|
|
||||||
int length = array.Length / batchSize * batchSize;
|
|
||||||
for (int i = 0; i < length; i += batchSize)
|
|
||||||
{
|
{
|
||||||
ulong value = BitConverter.ToUInt64(array, i);
|
array[i] ^= KEY;
|
||||||
value ^= BundleStream.KEY;
|
|
||||||
Buffer.BlockCopy(BitConverter.GetBytes(value), 0, array, i, batchSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user