The sensing distance and spatial resolution of phase-sensitive optical time domain reflectometer ( Ф-OTDR) are mutually restricted. In order to further improve the system performance, a random number coding method of optical pulse is proposed in this paper. The linearization theory analysis of the coherent detection Ф-OTDR based on coding and the principle of random number encoding and decoding are described, and the gain mathematical model of random number encoding is deduced. Experimental results show that compared with the single-pulse equivalent, the sensing distance can be increased from 25 km to 50. 26 km by using 128 bit random number code with 40 ns pulse width and 1 kHz pulse repetition frequency, and the signal to noise ratio can reach 17. 51 dB at 50. 22 km, where the vibration signal can be well restored. The research shows that the random number coding method provides an effective solution for improving the performance of Ф-OTDR.