From 77cb9a853f85f0f81bf0f0b9daf0ce04776522bc Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 24 Mar 2017 22:50:36 +0400 Subject: [PATCH] (KiriKiri.KissCrypt): new decryptor. --- ArcFormats/KiriKiri/CryptAlgorithms.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index 83ee80bd..0595a03a 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -954,4 +954,26 @@ namespace GameRes.Formats.KiriKiri [NonSerialized] Dictionary KnownNames = null; } + + [Serializable] + public class KissCrypt : ICrypt + { + public override void Decrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count) + { + uint key = entry.Hash ^ (entry.Hash >> 19) ^ 0x4A9EEFF0u; + int i = 0; + while (0 != ((offset + i) & 0xF)) + ++i; + while (i < count) + { + data[pos+i] ^= (byte)(key ^ (offset + i)); + i += 0x10; + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] data, int pos, int count) + { + Decrypt (entry, offset, data, pos, count); + } + } }