Hill Cipher

Encryption matrix :

M={{2,7,6},{4,5,13},{2,6,1}}

Message: HID ETH ISM ESS AGE

Plaintext matrix for this message:

P=Transpose[{{8,9,4},{5,20,8},{9,19,13},{5,19,19},{1,7,5}}](*to turn rows into columns*)

Code matrix that yields the encrypted message :

A=Mod[M.P,29]

Replace the numbers with letters to obtain the coded message: 
PMP XUV ZJ! YN, WQT

To decrypt, multiply the inverse of the encryption matrix M times the code matrix A :

Minverse=Mod[Det[M]^28 Inverse[M],29] (* special form of inverse so numbers stay between 0 and 28 *)

Mod[Minverse.A,29]

So we successfully returned to the plaintext message P.