mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(KiriKiri): another encryption scheme.
This commit is contained in:
parent
481b0995a7
commit
cb2b6e2f43
@ -744,7 +744,7 @@ namespace GameRes.Formats.KiriKiri
|
||||
Decrypt (entry, offset, buffer, pos, count);
|
||||
}
|
||||
|
||||
IEnumerable<byte> GetKey (uint hash)
|
||||
internal IEnumerable<byte> GetKey (uint hash)
|
||||
{
|
||||
hash = (hash ^ m_seed) & 0x7FFFFFFF;
|
||||
hash = hash << 31 | hash;
|
||||
@ -1142,4 +1142,29 @@ namespace GameRes.Formats.KiriKiri
|
||||
[NonSerialized]
|
||||
Dictionary<uint, string> KnownNames = null;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class MadoCrypt : AkabeiCrypt
|
||||
{
|
||||
public MadoCrypt (uint seed) : base (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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user