Is it possible to derive the key, for a playfair cipher, if both the message and cipher text are known?
There are two issues to be aware of.
Firstly if the message and cipher text are short, or lack variation in the usage of letters, there may not be enough information to recover a complete Playfair square,
Secondly, rotating all the rows or all the columns of a Playfair square gives an alternative square that encrypts in the same manner. Thus squares come in families of 25. If the “key” is a word or phrase, it is usually straightforward to recover the key used by the system. If the key is a “random” arrangement of 25 letters, then the precise key cannot be distinguished from the other 24 without more information.
If you're asking about the process for recovering the square given matched plain and cipher, this can be done manually and is relatively straightforward. Consider a common letter such as "E" and select all digraphs involving this letter. There are only 5 letters that can replace our chosen letter: the four with which it shares a row and the one directly beneath it. Suppose then we find that we find "E" can be encoded only as one of "ADFLX", now choose a common one of these an examine digraphs. For example we might find that "A" can only be encoded as "BEFLX", we can now conclude that one row contains the letters "AEFLX" and that "D" and "B" lie directly below "A" and "E" respectively. Now consider the letters apart from "ADFLX" that appear in digraphs with "E", within those digraphs these letters can only be encoded as either a letter that lies in the same column as "E", or a letter directly to the right. The ones encrypted to the right will share a column with "E" and "E" will be encoded to the same letter for each of these. These rules should allow you to reconstruct rows and columns of the square. The order of the rows and columns can only be inferred from encryptions of digraphs that share a row/column.