// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text; namespace E { public class Caesar { public static byte[] Encrypt(string s, int off) { byte[] res = new byte[s.Length]; for(int i = 0; i < s.Length; i++) res[i] = (byte)(s[i] + off); return res; } public static string Decrypt(byte[] b, int off) { StringBuilder res = new StringBuilder(); for(int i = 0; i < b.Length; i++) res.Append((char)(b[i] - off)); return res.ToString(); } } class MainClass { public static void Main(string[] args) { Console.WriteLine(Caesar.Decrypt(Caesar.Encrypt("Dette er en test", 5), 5)); } } }