Machine learning is a powerful tool in both cryptosystem and cryptanalysis. Intrusion detection is a significant part of cyber defence plans where improvements are needed to deal with the challenges such as detection of false alarms, everyday new threats, and enhancing performance and accuracy. In this chapter, an optimized deep learning model is proposed to detect intrusion using whale optimization algorithm (WOA) with light gradient boosting machine (LightGBM) algorithm. To increase the performance of the model, the collected network data from the KDD dataset are pre-processed with feature selection and dimensionality reduction methods. The WOA-LightGBM algorithm processes the pre-processed data for training. The outcomes of these experiments are compared with the performance of benchmarking algorithms to prove that this intrusion detection model provides better performance and accuracy. The proposed model detects the intrusion with high accuracy in short period of time.