From 83fa48b71dde357ff79d521678f6727e638e76f1 Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 10 Apr 2018 22:18:11 +0400 Subject: [PATCH] (NephriteCrypt): another KiriKiri encryption scheme. --- ArcFormats/KiriKiri/CryptAlgorithms.cs | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index 158333a6..5379392d 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -578,6 +578,34 @@ namespace GameRes.Formats.KiriKiri } } + [Serializable] + public class NephriteCrypt : ICrypt + { + public override byte Decrypt (Xp3Entry entry, long offset, byte value) + { + if (0 != (offset & 1)) + return (byte)(value ^ offset); + else + return (byte)(value ^ entry.Hash); + } + + public override void Decrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + for (int i = 0; i < count; ++i, ++offset) + { + if (0 != (offset & 1)) + values[pos+i] ^= (byte)offset; + else + values[pos+i] ^= (byte)entry.Hash; + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + Decrypt (entry, offset, values, pos, count); + } + } + [Serializable] public class GakuenButouCrypt : ICrypt {