(KiriKiri): another encryption scheme.

This commit is contained in:
morkt 2016-07-28 20:30:25 +04:00
parent 97a70d3fd4
commit 891b602a7f
2 changed files with 48 additions and 0 deletions

View File

@ -24,6 +24,8 @@
// //
using System; using System;
using System.Collections.Generic;
using System.Linq;
using GameRes.Utility; using GameRes.Utility;
namespace GameRes.Formats.KiriKiri namespace GameRes.Formats.KiriKiri
@ -696,4 +698,48 @@ namespace GameRes.Formats.KiriKiri
Decrypt (entry, offset, buffer, pos, count); Decrypt (entry, offset, buffer, pos, count);
} }
} }
[Serializable]
public class AkabeiCrypt : ICrypt
{
private readonly uint m_seed;
public AkabeiCrypt (uint seed)
{
m_seed = seed;
}
public override byte Decrypt (Xp3Entry entry, long offset, byte value)
{
int key_pos = (int)offset & 0x1F;
var key = GetKey (entry.Hash).ElementAt (key_pos);
return (byte)(value ^ key);
}
public override void Decrypt (Xp3Entry entry, long offset, byte[] buffer, int pos, int count)
{
var key = GetKey (entry.Hash).ToArray();
int key_pos = (int)offset;
for (int i = 0; i < count; ++i)
{
buffer[pos+i] ^= key[key_pos++ & 0x1F];
}
}
public override void Encrypt (Xp3Entry entry, long offset, byte[] buffer, int pos, int count)
{
Decrypt (entry, offset, buffer, pos, count);
}
IEnumerable<byte> GetKey (uint hash)
{
hash = (hash ^ m_seed) & 0x7FFFFFFF;
hash = hash << 31 | hash;
for (int i = 0; i < 0x20; ++i)
{
yield return (byte)hash;
hash = (hash & 0xFFFFFFFE) << 23 | hash >> 8;
}
}
}
} }

View File

@ -258,6 +258,7 @@ Se-kirara<br/>
Sharin no Kuni, Himawari no Shoujo<br/> Sharin no Kuni, Himawari no Shoujo<br/>
Shokusai no Miyako<br/> Shokusai no Miyako<br/>
Swan Song<br/> Swan Song<br/>
Teakamamire no Tenshi<br/>
Zecchou Spiral!!<br/> Zecchou Spiral!!<br/>
</td></tr> </td></tr>
<tr><td>*.tlg</td><td><tt>TLG0.0</tt><br/><tt>TLG5.0</tt><br/><tt>TLG6.0</tt></td><td>No</td></tr> <tr><td>*.tlg</td><td><tt>TLG0.0</tt><br/><tt>TLG5.0</tt><br/><tt>TLG6.0</tt></td><td>No</td></tr>
@ -632,6 +633,7 @@ Answer Dead<br/>
Houou Senki Maimu<br/> Houou Senki Maimu<br/>
Kango Sentai Nurse Ranger<br/> Kango Sentai Nurse Ranger<br/>
Megami Taisen<br/> Megami Taisen<br/>
Shouryuu Senki Tenmu<br/>
</td></tr> </td></tr>
<tr class="odd"><td>*.abm</td><td><tt>BM</tt></td><td>No</td></tr> <tr class="odd"><td>*.abm</td><td><tt>BM</tt></td><td>No</td></tr>
<tr><td>*.arc<br/>*.xarc<br/>*.bin</td><td><tt>MIKO</tt><br/><tt>KOTORI</tt><br/><tt>XARC</tt></td><td>No</td><td rowspan="2">Xuse<br/>ETERNAL</td><td rowspan="2"> <tr><td>*.arc<br/>*.xarc<br/>*.bin</td><td><tt>MIKO</tt><br/><tt>KOTORI</tt><br/><tt>XARC</tt></td><td>No</td><td rowspan="2">Xuse<br/>ETERNAL</td><td rowspan="2">