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;
- namespace Decrypter
- {
- class Program
- {
- static void Main(string[] args)
- {
- String input = "-1";
- while (input != "0")
- {
- Console.WriteLine("Wat wil je doen?");
- Console.WriteLine("1: Iets Caesar decoderen");
- Console.WriteLine("0: Sluiten");
- input = Console.ReadLine();
- switch (input)
- {
- case "1":
- CaesarMenu();
- break;
- case "0":
- Console.WriteLine("We sluiten...");
- break;
- default:
- Console.WriteLine("Ken ik niet...");
- break;
- }
- }
- }
- static void CaesarMenu()
- {
- String input = "-1";
- while (input != "0")
- {
- Console.WriteLine("Geef de Caesar code in ofwel een 0 om te stoppen");
- input = Console.ReadLine();
- if (input != "0")
- {
- Console.WriteLine("Geef nu de C in");
- int C = 17;
- Console.WriteLine("De output is= " + DecypherCaesar(input, C));
- }
- }
- }
- static String DecypherCaesar(String input, int C)
- {
- int strLen = input.Length;
- String output="";
- for (int i = 1; i <= strLen; i++)
- {
- int asc = Convert.ToInt32(Convert.ToSByte(input[i - 1]));
- if(asc >= 65 && asc <= 90){
- asc = asc - C;
- if(asc < 65){
- if (asc == 64)
- asc = 32;
- else
- asc = asc + 27;
- }
- }
- output+=char.ConvertFromUtf32(asc);
- }
- return output;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement