· 9 years ago · Sep 23, 2016, 04:36 PM
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Diagnostics;
6
7namespace WindowsFormsApplication31
8{
9 public enum Mode
10 {
11 Encode,
12 Decode
13 }
14 public static class Crypt
15 {
16 public static string cesarShift(string plainText, int secretKey, Mode mode)
17 {
18 string cipherText = "";
19
20 foreach (Char c in plainText)
21 {
22 char _c = ' ';
23
24 if(mode == Mode.Encode) _c = (char)(c + secretKey);
25 else if (mode == Mode.Decode) _c = (char)(c - secretKey);
26
27 cipherText += _c.ToString();
28 }
29
30 return cipherText;
31 }
32 }
33}