Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 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 Task4
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.Write("Enter a String : ");
  14. string input = Console.ReadLine().ToUpper();
  15.  
  16. char[] inputarray = input.ToArray();
  17. String alphabets = "ABCDEFGHIJKLMNOPQRSTUVYXWZ";
  18. String cipherAlphabtes = "DEFGHIJKLMNOPQRSTUVWXYZABC";
  19.  
  20. Console.WriteLine("Applying Caesar cipher");
  21.  
  22.  
  23. String cipherText = "";
  24.  
  25. foreach (char letters in inputarray)
  26. {
  27. int pos = alphabets.IndexOf(letters);
  28. if (pos >= 0)
  29. {
  30. cipherText += cipherAlphabtes[pos];
  31. }
  32. }
  33.  
  34. Console.WriteLine("Plain Text = " + input);
  35. Console.WriteLine("Cipher Text = " + cipherText);
  36. Console.ReadKey();
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement