diff --git a/PangLib.UpdateList/UpdateList.cs b/PangLib.UpdateList/UpdateList.cs index a827fd2..6548141 100644 --- a/PangLib.UpdateList/UpdateList.cs +++ b/PangLib.UpdateList/UpdateList.cs @@ -31,7 +31,7 @@ public UpdateList(string filePath) /// /// Saves the parsed updatelist in the Document instance attribute /// - public void Parse() + public void Parse(bool decrypt = true) { if (DecryptionKey == null) { @@ -39,15 +39,27 @@ public void Parse() } Span updateList = File.ReadAllBytes(FilePath); - - for (int i = 0; i < updateList.Length; i += 8) +if(decrypt) +{ for (int i = 0; i < updateList.Length; i += 8) { Span chunk = updateList.Slice(i, 8); Span decrypted = XTEA.Decipher(16, MemoryMarshal.Cast(chunk).ToArray(), DecryptionKey); Span resource = MemoryMarshal.AsBytes(decrypted); resource.CopyTo(chunk); } +} + else + { + var newArray = new byte[updateList.Length - updateList.Length % 8 + 8]; + updateList.CopyTo(newArray); + updateList = newArray; + for (int i = 0; i < updateList.Length; i += 8) + { + Span chunk = updateList.Slice(i, 8); + MemoryMarshal.AsBytes(XTEA.Encipher(16, MemoryMarshal.Cast(chunk).ToArray(), DecryptionKey)).CopyTo(chunk); + } + } Document = Encoding.UTF8.GetString(updateList.ToArray()); }