From 57ceb5794bf99706c4a7e7ac1dc96ea1773c4798 Mon Sep 17 00:00:00 2001 From: Crsky Date: Sun, 28 Sep 2025 01:37:54 +0800 Subject: [PATCH] (ShiinaRio): Added Ushimitsu2Crypt --- ArcFormats/ShiinaRio/WarcEncryption.cs | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ArcFormats/ShiinaRio/WarcEncryption.cs b/ArcFormats/ShiinaRio/WarcEncryption.cs index 0dee3078..f461a064 100644 --- a/ArcFormats/ShiinaRio/WarcEncryption.cs +++ b/ArcFormats/ShiinaRio/WarcEncryption.cs @@ -1316,4 +1316,43 @@ namespace GameRes.Formats.ShiinaRio } } } + + [Serializable] + public class Ushimitsu2Crypt : IDecryptExtra + { + public void Decrypt (byte[] data, int index, uint length, uint flags) + { + byte[] key = new byte[] + { + 0x4B, 0x4D, 0x36, 0x35, 0x33, 0x32, 0x20, 0x43, + 0x50, 0x55, 0x20, 0x63, 0x6F, 0x72, 0x65, 0x20, + 0x65, 0x6D, 0x75, 0x6C, 0x61, 0x74, 0x69, 0x6F, + 0x6E, 0x20, 0x3A, 0x20, 0x43, 0x6F, 0x70, 0x79, + 0x72, 0x69, 0x67, 0x68, 0x74, 0x28, 0x43, 0x29, + 0x20, 0x32, 0x30, 0x30, 0x35, 0x2C, 0x36, 0x20, + 0x59, 0x2E, 0x59, 0x61, 0x6D, 0x61, 0x64, 0x61, + 0x2F, 0x53, 0x54, 0x55, 0x44, 0x49, 0x4F, 0x20, + 0x82, 0xE6, 0x82, 0xB5, 0x82, 0xAD, 0x82, 0xF1 + }; + + if (length >= 0x200) + { + if ((flags & 0x202) == 0x202) + { + for (int i = 0; i < ((length & 0x7E) | 1); i++) + { + data[index+i] ^= key[i % 0x40]; + } + var value = MemoryMarshal.Read (data.AsSpan (index+0x100)); + value ^= length; + MemoryMarshal.Write (data.AsSpan (index+0x100), ref value); + } + } + } + + public void Encrypt (byte[] data, int index, uint length, uint flags) + { + throw new NotImplementedException (); + } + } }