Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication9
- {
- class Program
- {
- public static int[,] key { get; set; }
- public static string CreatetheCipher(string plainText, int rowsize, int colsize)
- {
- char[] chArray1 = plainText.ToCharArray();
- int[,] numArray = new int[3, 3];
- int num1 = 0;
- int index1 = 0;
- int num2 = Enumerable.Count<char>((IEnumerable<char>)chArray1);
- for (int index2 = 0; index2 < rowsize; ++index2)
- {
- for (int index3 = 0; index3 < colsize; ++index3)
- {
- if (index1 < num2)
- {
- if (char.IsUpper(chArray1[index1]))
- num1 = Convert.ToInt32((int)chArray1[index1] - 65);
- numArray[index2, index3] = num1;
- ++index1;
- }
- else
- numArray[index2, index3] = 0;
- }
- }
- int num3 = 0;
- char[,] chArray2 = new char[3, 3];
- for (int index2 = 0; index2 < rowsize; ++index2)
- {
- for (int index3 = 0; index3 < colsize; ++index3)
- {
- for (int index4 = 0; index4 < 3; ++index4)
- num3 += key[index2, index4] * numArray[index4, index3];
- char ch = (char)num3;
- chArray2[index2, index3] = ch;
- num3 = 0;
- }
- }
- string str = string.Empty;
- for (int index2 = 0; index2 < 3; ++index2)
- {
- for (int index3 = 0; index3 < 3; ++index3)
- str = str + (object)chArray2[index2, index3];
- }
- return str;
- }
- static void Main(string[] args)
- {
- String x = "SWEETLORD-OlUXOmMhEiQO";
- Console.WriteLine(CreatetheCipher(x, 3, 5));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement