From 1b317ae539c6f9a4682c0b50896c27cbff42d765 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 8 Sep 2016 17:55:34 +0400 Subject: [PATCH] (KiriKiri): 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 ea3d6e9f..4d94ad6a 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -742,4 +742,27 @@ namespace GameRes.Formats.KiriKiri } } } + + [Serializable] + public class HaikuoCrypt : ICrypt + { + public override byte Decrypt (Xp3Entry entry, long offset, byte value) + { + return (byte)(value ^ entry.Hash ^ (entry.Hash >> 8)); + } + + public override void Decrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + byte key = (byte)(entry.Hash ^ (entry.Hash >> 8)); + for (int i = 0; i < count; ++i) + { + values[pos+i] ^= key; + } + } + + public override void Encrypt (Xp3Entry entry, long offset, byte[] values, int pos, int count) + { + Decrypt (entry, offset, values, pos, count); + } + } }