public override void Encrypt(Xp3Entry entry, long offset, byte[] values, int pos, int count) { throw new NotImplementedException (Strings.arcStrings.MsgEncNotImplemented); // despite the fact that algorithm is symmetric, creating an archive without updating "list.bin" // wouldn't make much sense // Decrypt (entry, offset, values, pos, count); }
public override void Decrypt(Xp3Entry entry, long offset, byte[] values, int pos, int count) { uint limit = GetEncryptionLimit (entry); uint key = entry.Hash; for (int i = 0; i < count && offset < limit; ++i, ++offset) { values[pos+i] ^= (byte)(offset ^ (key >> (((int)offset & 3) << 3))); } }
public override void Encrypt(Xp3Entry entry, long offset, byte[] values, int pos, int count) { Decrypt (entry, offset, values, pos, count); }
public override void Decrypt(Xp3Entry entry, long offset, byte[] buffer, int pos, int count) { uint key = entry.Hash; uint base_offset = GetBaseOffset (key); if (offset < base_offset) { int base_length = Math.Min ((int)(base_offset - offset), count); Decode (key, offset, buffer, pos, base_length); offset += base_length; pos += base_length; count -= base_length; } if (count > 0) { key = (key >> 16) ^ key; Decode (key, offset, buffer, pos, count); } }
public override byte Decrypt(Xp3Entry entry, long offset, byte value) { uint key = entry.Hash; uint base_offset = GetBaseOffset (key); if (offset >= base_offset) { key = (key >> 16) ^ key; } var buffer = new byte[1] { value }; Decode (key, offset, buffer, 0, 1); return buffer[0]; }
uint GetEncryptionLimit(Xp3Entry entry) { uint limit; if (EncryptionThresholdMap != null && EncryptionThresholdMap.TryGetValue (entry.Hash, out limit)) return limit; else return 0x200; }