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 Task4
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter a String : ");
- string input = Console.ReadLine().ToUpper();
- char[] inputarray = input.ToArray();
- String alphabets = "ABCDEFGHIJKLMNOPQRSTUVYXWZ";
- String cipherAlphabtes = "DEFGHIJKLMNOPQRSTUVWXYZABC";
- Console.WriteLine("Applying Caesar cipher");
- String cipherText = "";
- foreach (char letters in inputarray)
- {
- int pos = alphabets.IndexOf(letters);
- if (pos >= 0)
- {
- cipherText += cipherAlphabtes[pos];
- }
- }
- Console.WriteLine("Plain Text = " + input);
- Console.WriteLine("Cipher Text = " + cipherText);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement