You need to read a great novel called Cryptonomicon, which is about code breaking in WWII and Encryption on the internet.
Basically, most codes are substitution codes. You substitute one symbol for each letter. For example you can have a two shift code in which each letter is represented by the letter two letters down the alphabet,
so
ABC =
CDE
That's a simple code. Another way that is harder is to have a prearranged way to generate a number, for example, using the date, like today is the 8th, so today's code shifts eight places in the alphabet.
The more complicated codes can shift for each letter. So if today it the 8th, the letter A is shifted over eight letters, say G, then the next letter in the alphabet, B, is shifted over 9 letters, and the next is shifted over ten.
The best encryptions use something called a one-time pad, where each of you have a key that is agreed upon that will be used only once. Those are almost impossible to break without a computer.
In Pathfinder terms, I would say Linguistics would work. As long as you know the language the code is in, A simple substitution code would be DC 20, a shifted code DC 25, an evolving shift DC 35.
However, given the presence of such magics as comprehend languages and divination spells like augury "Weal or Woe if I use a substitution code to try and break this code?" I can't see how codes could be much use.
A better solution would be something like a magic mouth given specific conditions who to speak to and what to say. Then there's spell like sending and animal messenger as well.