using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication7
{
class Program
{
static string s = "";
static string[,] arr;
static void Main(string[] args)
{
int ch = 1;
while (ch == 1||ch==2)
{
Console.WriteLine("Enter 1 for Ciphering \n Enter 2 for Deciphering");
ch = Convert.ToInt32(Console.ReadLine());
if (ch == 1)
cipher();
else if (ch == 2)
decipher();
else
Console.WriteLine("Wrong input");
}
Console.ReadKey();
}
static void cipher()
{
int ch = 1,i=0,r=0,j=0,r2=0,c2=0,column=6,col=0;
Console.WriteLine("Enter simple text");
s = Console.ReadLine();
r=(s.Length+5)/6;
arr = new string[r, 6];
Console.WriteLine("Enter Number of Rounds");
ch = Convert.ToInt32(Console.ReadLine());
if (ch <= 0)
{
Console.WriteLine("Wrong input");
return;
}
for (i = 1; i <= ch; i++)
{
for (j = 0; j < s.Length; j++)
{
arr[r2, c2] = s[j].ToString();
c2++;
if (c2 > 5)
{ r2 += 1;
c2 =0;
}
}
Console.WriteLine("Choose column number");
s = "";
while (column > 0)
{
col = Convert.ToInt32(Console.ReadLine());
if(r2<0)
while (col <= c2)
{
if (col > c2||col>5)
Console.WriteLine("Re - enter the column number");
}
for (j = 0; j <=r2; j++)
s = s + arr[j, col];
column -= 1;
//Console.WriteLine(s);
}
Console.WriteLine(s);
r2 = 0; c2 = 0; column = 6; col = 0;
}
}
static void decipher()
{ }
}
}
Comments