From 8c758668f26ff855688ce978a40954b2de6b0057 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 25 Oct 2018 16:49:28 +0400 Subject: [PATCH] (XP3): another encryption algorithm. --- ArcFormats/KiriKiri/CryptAlgorithms.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index 5379392d..55990c4d 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -1270,4 +1270,27 @@ namespace GameRes.Formats.KiriKiri Decrypt (entry, offset, buffer, pos, count); } } + + [Serializable] + public class FestivalCrypt : ICrypt + { + public override byte Decrypt (Xp3Entry entry, long offset, byte value) + { + return (byte)(value ^ (entry.Hash >> 7) ^ 0xFF); + } + + public override void Decrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count) + { + byte key = (byte)~(entry.Hash >> 7); + for (int i = 0; i < count; ++i) + { + data[pos+i] ^= key; + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count) + { + Decrypt (entry, offset, data, pos, count); + } + } }