diff --git a/FGOAssetsModifyTool/CatAndMouseGame.cs b/FGOAssetsModifyTool/CatAndMouseGame.cs index 6945270..b40a7a3 100644 --- a/FGOAssetsModifyTool/CatAndMouseGame.cs +++ b/FGOAssetsModifyTool/CatAndMouseGame.cs @@ -286,14 +286,14 @@ public byte[] MouseGame4(byte[] data, string key) public byte[] CatHomeMain(byte[] data, byte[] home, byte[] info, bool isCompress = false) { - byte[] result = null; + byte[] result = data; try { if (isCompress) { - using (MemoryStream inStream = new MemoryStream(data)) + using (MemoryStream inStream = new(data)) { - using (MemoryStream outStream = new MemoryStream()) + using (MemoryStream outStream = new()) { if (fileType == FileType.CN) { @@ -312,9 +312,7 @@ public byte[] CatHomeMain(byte[] data, byte[] home, byte[] info, bool isCompress var keyParam = new KeyParameter(home); var keyParamWithIV = new ParametersWithIV(keyParam, info, 0, 32); cipher.Init(true, keyParamWithIV); - var buffer = new byte[cipher.GetOutputSize(result.Length)]; - var length = cipher.ProcessBytes(result, buffer, 0); - cipher.DoFinal(buffer, length); + var buffer = cipher.DoFinal(result); result = buffer; } catch (Exception ex) @@ -335,16 +333,7 @@ public static byte[] MouseHomeMain(byte[] data, byte[] home, byte[] info, bool i var keyParam = new KeyParameter(home); var keyParamWithIV = new ParametersWithIV(keyParam, info, 0, 32); cipher.Init(false, keyParamWithIV); - var buffer = new byte[cipher.GetOutputSize(data.Length)]; - var length = cipher.ProcessBytes(data, buffer, 0); - cipher.DoFinal(buffer, length); - - if (buffer.Length != length) - { - var tmp = new byte[length]; - Array.Copy(buffer, 0, tmp, 0, length); - buffer = tmp; - } + var buffer = cipher.DoFinal(data); if (isCompress) { diff --git a/FGOAssetsModifyTool/Program.cs b/FGOAssetsModifyTool/Program.cs index 4201d9e..4918d23 100644 --- a/FGOAssetsModifyTool/Program.cs +++ b/FGOAssetsModifyTool/Program.cs @@ -22,9 +22,10 @@ static async void DisplayMenuAsync() try { Console.WriteLine( - "初始化顺序:3->7->4->6->0\n" + - "之后直接选择:0\n" + - "注意:日服的AssetStorage.txt必须选择4下载,从游戏中提取的格式不同\n" + + "注意:日服第一次使用之前需要初始化,初始化顺序:3->7->4->6->0\n" + + "之后运行直接选择:0\n" + + "当然,如果有新的资源,也需要重新初始化一遍。\n" + + "日服的AssetStorage.txt必须选择4下载,从游戏中提取的格式不同。\n" + "0: 载入assetbundleinfo\n" + "1: 加密\t" + "2: 解密\n" + @@ -473,7 +474,7 @@ static async void DisplayMenuAsync() if (ScriptReplaceRules.Count != 0) { - foreach(var rule in ScriptReplaceRules) + foreach (var rule in ScriptReplaceRules) { OutputTxt = OutputTxt.Replace(rule.Key, rule.Value); }