Example #1
0
        private string Encrypt(string clearedInput, TableSize tableSize)
        {
            var encryptedResult = new StringBuilder();

            for (int j = 0; j < tableSize.Columns; j++)
            {
                if (j != 0)
                {
                    encryptedResult.Append(" ");
                }
                for (int i = 0; i < tableSize.Rows; i++)
                {
                    var index = CalculateOrderNum(i, j, tableSize);
                    if (index >= clearedInput.Length)
                    {
                        break;
                    }
                    encryptedResult.Append(clearedInput[index]);
                }
            }

            return(encryptedResult.ToString());
        }
Example #2
0
 private int CalculateOrderNum(int rowNum, int columnNum, TableSize tableSize)
 {
     return(rowNum * tableSize.Columns + columnNum);
 }