It has been demonstrated that performing packet classification on a potentially large number of filters on key header fields is difficult and has poor worst-case performance. To achieve fast packet classification, hardware support is unavoidable. Ternary content-addressable memory (TCAM) has been widely used to perform fast packet classification due to its ability to solve the problem in O(1) time without considering the number of entries, mask continuity and their lengths. As compared to the software-based solutions, the TCAM can offer sustained throughput and simple system architecture. It is attractive for packet classification, especially for the ultimate IPv6-based networks. However, it also comes with several shortcomings, such as the limited number of entries, expansive cost and power consumption. Accordingly, we propose an efficient algorithm to reduce the required TCAM by encoding the address portion of the searchable entries. The new scheme could encrypt the 128-bit prefixes of the real-world IPv6 routing tables into 11 bits and still keeps the property of CIDR.