Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication9
  8. {
  9. class Program
  10. {
  11. public static int[,] key { get; set; }
  12.  
  13. public static string CreatetheCipher(string plainText, int rowsize, int colsize)
  14. {
  15. char[] chArray1 = plainText.ToCharArray();
  16. int[,] numArray = new int[3, 3];
  17. int num1 = 0;
  18. int index1 = 0;
  19. int num2 = Enumerable.Count<char>((IEnumerable<char>)chArray1);
  20. for (int index2 = 0; index2 < rowsize; ++index2)
  21. {
  22. for (int index3 = 0; index3 < colsize; ++index3)
  23. {
  24. if (index1 < num2)
  25. {
  26. if (char.IsUpper(chArray1[index1]))
  27. num1 = Convert.ToInt32((int)chArray1[index1] - 65);
  28. numArray[index2, index3] = num1;
  29. ++index1;
  30. }
  31. else
  32. numArray[index2, index3] = 0;
  33. }
  34. }
  35. int num3 = 0;
  36. char[,] chArray2 = new char[3, 3];
  37. for (int index2 = 0; index2 < rowsize; ++index2)
  38. {
  39. for (int index3 = 0; index3 < colsize; ++index3)
  40. {
  41. for (int index4 = 0; index4 < 3; ++index4)
  42. num3 += key[index2, index4] * numArray[index4, index3];
  43. char ch = (char)num3;
  44. chArray2[index2, index3] = ch;
  45. num3 = 0;
  46. }
  47. }
  48. string str = string.Empty;
  49. for (int index2 = 0; index2 < 3; ++index2)
  50. {
  51. for (int index3 = 0; index3 < 3; ++index3)
  52. str = str + (object)chArray2[index2, index3];
  53. }
  54. return str;
  55. }
  56.  
  57. static void Main(string[] args)
  58. {
  59. String x = "SWEETLORD-OlUXOmMhEiQO";
  60. Console.WriteLine(CreatetheCipher(x, 3, 5));
  61. Console.ReadKey();
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement