예제 #1
0
        /// <summary>
        /// Decrypt Packet
        /// </summary>
        public void DecryptPacket(CString Packet)
        {
            // Encryption Type
            Encrypt.Type EncryptType = Encrypt.Type.UNCOMPRESSED;

            // Generation Type
            switch (mCodec.Gen)
            {
            // Unencrypted Packets
                case Encrypt.Generation.GEN1:
                case Encrypt.Generation.GEN2:
                    return;

            // Zlib
                case Encrypt.Generation.GEN3:
                    mCodec.Apply(Encrypt.CryptType.DECRYPT, Packet, Encrypt.Type.UNCOMPRESSED);
                    return;

            // BZip2
                case Encrypt.Generation.GEN4:
                    EncryptType = Encrypt.Type.BZ2;
                    break;

            // BZip2 / Zlib
                case Encrypt.Generation.GEN5:
                    EncryptType = (Encrypt.Type)Packet.ReadByte();
                    Packet.Remove(0, 1);
                    break;
            }

            // Decrypt Packet
            mCodec.Apply(Encrypt.CryptType.DECRYPT, Packet, EncryptType);

            // Uncompress Packet
            if (EncryptType == Encrypt.Type.ZLIB)
                Packet.ZDecompress();
            else if (EncryptType == Encrypt.Type.BZ2)
                Packet.BDecompress();
        }