As a new communication technology, Intelligent Reflecting Surface (IRS) can intelligently reconfigure the wireless propagation environment by integrating many passive/active reflective elements on the plane. According to the characteristics that IRS can adjust the propagation channel intelligently, this paper applies IRS to wireless security communication, and studies how to make the security rate reach the optimal security capacity from the perspective of optimization technology. In this paper, two schemes of passive/active IRS are considered, and the corresponding safety rate maximization algorithm is proposed. In view of the nonconvexity of the objective function, on the one hand, in the passive IRS scheme, the Dinkelbach method is used to transform the objective function into a form that is easy to handle, and the original problem is transformed into a convex problem through the continuous convex approximation method; On the other hand, under the active IRS scheme, aiming at the complexity of the original problem, the first order Taylor expansion is used to obtain the lower bound of the optimization problem, and a minimax optimization algorithm is proposed. Finally, the performance of the proposed algorithm is verified by simulation. The simulation results show that the algorithm designed with active IRS has better security rate than the algorithm designed with passive IRS under the same parameter settings.