示例#1
0
 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);
 }
示例#2
0
 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)));
     }
 }
示例#3
0
 public override void Encrypt(Xp3Entry entry, long offset, byte[] values, int pos, int count)
 {
     Decrypt (entry, offset, values, pos, count);
 }
示例#4
0
 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);
     }
 }
示例#5
0
 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];
 }
示例#6
0
 uint GetEncryptionLimit(Xp3Entry entry)
 {
     uint limit;
     if (EncryptionThresholdMap != null && EncryptionThresholdMap.TryGetValue (entry.Hash, out limit))
         return limit;
     else
         return 0x200;
 }