A theoretical model is proposed to analyze the time-domain spectral phase en/decoding and evaluate the unconditional security of the optical code-based secure optical communication systems with DPSK modulation. The confidentiality of the systems with and without bit-by-bit code scrambling technique is investigated. It mathematically proves that the system without code scrambling lacks confidentiality and the system employing code scrambling can realize unconditionally secure transmission. Furthermore, encoding only within the central band of the spectrum is sufficient for perfect secrecy, and the secrecy rate can be potentially improved. It allows the system to operate in the burst mode for code generation and encoding and thus have an idle time for rearm.