Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Fixed a little bug...
Browse files Browse the repository at this point in the history
  • Loading branch information
hexstr committed Nov 1, 2022
1 parent 38e5964 commit ab7ab27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
21 changes: 5 additions & 16 deletions FGOAssetsModifyTool/CatAndMouseGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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)
{
Expand Down
9 changes: 5 additions & 4 deletions FGOAssetsModifyTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ab7ab27

Please sign in to comment.