Encoding and decoding may be almost as old as writing itself.
This past summer I read "Treason by the Book," a fascinating work by Yale University professor Jonathan D. Spence set in 18th-century China. It seems a scholar named Zha Siting (1664-1727) was charged with intrigues against the imperial court. He had allegedly asked students taking an examination to comment on a passage from the philosophical classic 大学 ("Daigaku"; "The Great Learning") that read, "Where the people rest."
"If one juxtaposed the first and the last characters of the four-character phrase," Spence writes, "one came up with two characters that were recognizable as the reign name of the current emperor, but in each case missing the top stroke. Zha Siting, in other words, had been luring the students to think of beheading their emperor."