The code implements a classic encryption technique to be reused in other project where security required is of intermediate level.
The algorithm write the given string in a 2-D array whose columns are based on the length of the key. Then the string is read on a column by column basis in the order of the key.
For example if the string to encode is "ThisWorldIsAMystery" and key is 34125 then the 2D array will be created like:
some characters are appended at the end to fill the array.
It will be read like this, 1st column, 2nd column, 3rd column and so on. The encoded string will become "ilMrsdyyTosthrAeWIsx".
The decryption will definitely be its reverse :)