A common challenge in cybersecurity is to automate the processes that ensure the security goals of confidentiality, integrity and availability of a system. In this lecture, we show how some of these processes can be turned into optimization problems to be tackled with Evolutionary Algorithms (EA). Specifically, we consider the case of automatically designing Boolean functions for symmetric encryption algorithms with EA, and how to leverage Genetic Programming (GP) as a supervised learner for anomaly-based network intrusion detection.