Since the 21st century, the degree of informatization has been greatly accelerated, which has brought great convenience to people's life. Moreover the problem of computer network security has become a crucial point in the development of information technology. How to protect network security and safeguard their own rights and interests are the problems faced by network security. Artificial intelligence technology is also developing with the progress of information technology. This study proposed the application of artificial intelligence in computer safety protection by combining artificial intelligence with computer network security. Artificial intelligence based Trojan horse detection model was established and tested. The experimental results demonstrated that the proposed artificial intelligence model could accurately and rapidly detect out Trojan horse program, with a low false alarm rate and missing alarm rate, suggesting favorable performance. This work provides a reference for the application of artificial intelligence technology in computer network security.