Пример #1
0
        private byte[] Encrypt(byte[] data)
        {
            var isX7 = Name.EndsWith(".x7", StringComparison.InvariantCultureIgnoreCase);

            if (Name.EndsWith(".lua", StringComparison.InvariantCultureIgnoreCase) || isX7)
            {
                if (isX7)
                {
                    data = S4Crypto.EncryptX7(data);
                }
                data = S4Crypto.EncryptAES(data);
                S4Crypto.Encrypt(data);
            }

            Length = data.Length;

            S4Crypto.EncryptCapped(data);
            if (data.Length < 1048576)
            {
                data = miniLzo.Compress(data);
            }
            S4Crypto.SwapBytes(data);

            return(data);
        }
Пример #2
0
        public static long ComputeHash(byte[] data, string fullName)
        {
            long dataCRC  = Hash.GetUInt32 <CRC32>(data);
            long pathCRC  = Hash.GetUInt32 <CRC32>(Encoding.ASCII.GetBytes(fullName));
            var  finalCRC = dataCRC | (pathCRC << 32);

            var tmp = BitConverter.GetBytes(finalCRC);

            S4Crypto.EncryptCapped(tmp);
            return(BitConverter.ToInt64(tmp, 0));
        }
Пример #3
0
 private byte[] EncryptEntry(byte[] data)
 {
     S4Crypto.EncryptCapped(data);
     return(data);
 }