From e0a75a6ab84a4caf08470849a772c91ad0836029 Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 11 Sep 2016 14:38:22 +0400 Subject: [PATCH] (KiriKiri.ExaCrypt): another encryption scheme. --- ArcFormats/KiriKiri/CryptAlgorithms.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index 809f6c8a..549993da 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -799,4 +799,27 @@ namespace GameRes.Formats.KiriKiri } } } + + [Serializable] + public class ExaCrypt : ICrypt + { + public override byte Decrypt (Xp3Entry entry, long offset, byte value) + { + return (byte)(value ^ (entry.Hash >> (int)((uint)offset % 5))); + } + + public override void Decrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + int shift = (int)(offset % 5); + for (int i = 0; i < count; ++i) + { + values[pos+i] ^= (byte)(entry.Hash >> ((shift+i) % 5)); + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + Decrypt (entry, offset, values, pos, count); + } + } }