This commit is contained in:
Chenx221 2025-01-01 18:30:09 +08:00
parent 6c56de559b
commit 6ccc6adf81
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
3 changed files with 11 additions and 12 deletions

View File

@ -28,30 +28,29 @@ namespace minitool3
{
byte[] fileData = File.ReadAllBytes(filePath);
if (fileData.Length < 20) // 4 bytes (size) + 16 bytes (IV)
if (fileData.Length < 16)
{
Console.WriteLine("The file does not contain enough data for size and IV.");
Console.WriteLine("The file does not contain enough data.");
continue;
}
// Read the encrypted data & iv size (4 bytes)
// Read the encrypted data & iv size (4 bytes)*
int encryptedSize = BitConverter.ToInt32(fileData, 0);
if (encryptedSize <= 0 || encryptedSize > fileData.Length - 4)
int sp = 4;
if (fileData.Length - 4 != encryptedSize) //*某些情况下头部不带长度
{
Console.WriteLine("Invalid encrypted data size.");
continue;
sp = 0;
encryptedSize = fileData.Length;
}
encryptedSize -= 16;
// Read the IV (16 bytes)
byte[] iv = new byte[16];
Array.Copy(fileData, 4, iv, 0, 16);
Array.Copy(fileData, sp, iv, 0, 16);
// Read the ciphertext based on the size
byte[] cipherText = new byte[encryptedSize];
Array.Copy(fileData, 20, cipherText, 0, encryptedSize);
Array.Copy(fileData, 16 + sp, cipherText, 0, encryptedSize);
byte[] decryptedData = Decrypt(cipherText, SHA256Byte, iv);

View File

@ -2,7 +2,7 @@
"profiles": {
"minitool3": {
"commandName": "Project",
"commandLineArgs": "\"G:\\source\\minitool1\\minitool3\\bin\\Debug\\net8.0\\bg_avg_003.jp.encrypted\""
"commandLineArgs": "\"G:\\source\\minitool1\\minitool3\\bin\\Release\\net8.0\\publish\\win-x64\\jp.co.dmm.dmmgames.imys_r\\files\\assetbundles\\characters\\tati\\020g2.encrypted\""
}
}
}

View File

@ -1,6 +1,6 @@
*.encrypted文件结构
(D)
4B: enc data + iv size
4B: enc data + iv size 这4B可能没有
16B: iv
{data size}B: enc data(AES256 encryption)