This paper presents mathematical relations in linear network coding and proposes a key pre-distribution-based tag encoding (KEPTE) scheme to detect polluted data packets. This paper also quantitatively gave the security analysis of KEPTE and compared its performance and overhead with other schemes. The main advantages of KEPTE can be summarized as: 1) It is computationally efficient; 2) All intermediate nodes and sinks are able to detect pollution attack and tag pollution attack; The basic idea of KEPTE is as follows: A source s uses N keys to generate N tags for each data packet. Each node g except the source holds a unique pair of keys {Zg, Vg}, where Zg, Vg, and the N keys held by s satisfy a certain relation.