2 dimensional arrays and encryption

Ok individually i can do both but im not sure where to start when putting these two together.

Bassically i want to read words from a text file then encrypt them in a two dimensional array.

So say the first word is MATHEMATICS id first want to remove the duplicated letters then place the remaining letters in a 5x5 array filling the rest of the space with the ramaining letters of the alphabet:

M A T H E

I C S B D

F G K L N

O P Q R U

V W X Y Z

The encryption would then be done by creating a rectangle so corners M and K. Then swap the letters on each corner so M would be T and F would be K

Hope this makes sense and any help is appreciated.