mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
(KiriKiri): another encryption scheme.
This commit is contained in:
parent
97a70d3fd4
commit
891b602a7f
@ -24,6 +24,8 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.KiriKiri
|
||||
@ -696,4 +698,48 @@ namespace GameRes.Formats.KiriKiri
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,6 +258,7 @@ Se-kirara<br/>
|
||||
Sharin no Kuni, Himawari no Shoujo<br/>
|
||||
Shokusai no Miyako<br/>
|
||||
Swan Song<br/>
|
||||
Teakamamire no Tenshi<br/>
|
||||
Zecchou Spiral!!<br/>
|
||||
</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/>
|
||||
Kango Sentai Nurse Ranger<br/>
|
||||
Megami Taisen<br/>
|
||||
Shouryuu Senki Tenmu<br/>
|
||||
</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">
|
||||
|
Loading…
x
Reference in New Issue
Block a user