CNUnity update, bug fixes.

This commit is contained in:
Razmoth
2023-02-16 21:42:02 +04:00
parent d4ea97524d
commit 8e39846caa
7 changed files with 99 additions and 64 deletions

View File

@@ -49,7 +49,7 @@ namespace AssetStudio
{
using var aes = Aes.Create();
aes.Mode = CipherMode.ECB;
aes.Key = Encoding.UTF8.GetBytes(entry.Key);
aes.Key = entry.GenerateKey();
Encryptor = aes.CreateEncryptor();
}
@@ -140,24 +140,18 @@ namespace AssetStudio
public bool Validate()
{
try
var bytes = GenerateKey();
if (bytes.Length != 0x10)
{
var bytes = Encoding.UTF8.GetBytes(Key);
if (bytes.Length != 0x10)
{
Logger.Warning($"[CNUnity] {this} has invalid key, size should be 16 bytes, skipping...");
return false;
}
}
catch(Exception e)
{
Logger.Error($"[CNUnity] Error while adding {this}: {e.Message}");
Logger.Warning($"[CNUnity] {this} has invalid key, size should be 16 bytes, skipping...");
return false;
}
return true;
}
public byte[] GenerateKey() => Convert.FromHexString(Key);
public override string ToString() => $"{Name} ({Key})";
}
}