A scheme for optical encryption/decryption of an eight-phase-shift keying (8PSK) signal is proposed, and this scheme applies modified optical XOR gates based on four-wave mixing (FWM) in a semiconductor optical amplifier (SOA). Theoretical analyses and simulations are conducted. Both the performance and the parameter design of a 40-Gbit/s all-optical encryption/decryption system under various key parameters are studied. The results are useful for designing optical encryption/decryption for complex modulated signals.