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); }
private byte[] Encrypt(byte[] data) { var cipher = S4Crypto.EncryptAES(data); S4Crypto.Encrypt(cipher); return(cipher); }
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)); }
public static byte[] DecryptS4(byte[] data) { int realSize; byte[] buffer; using (var r = data.ToBinaryReader()) { realSize = r.ReadInt32(); buffer = r.ReadToEnd(); } S4Crypto.Decrypt(buffer, 0, 0); return(miniLzo.Decompress(buffer, realSize)); }
public static byte[] EncryptS4(byte[] data) { var realSize = data.Length; var buffer = miniLzo.Compress(data); S4Crypto.Encrypt(buffer, 0, 0); using (var w = new BinaryWriter(new MemoryStream())) { w.Write(realSize); w.Write(buffer); return(w.ToArray()); } }
private byte[] DecryptEntry(byte[] data) { S4Crypto.DecryptCapped(data); return(data); }
private byte[] Decrypt(byte[] data) { S4Crypto.Decrypt(data); return(S4Crypto.DecryptAES(data)); }