// 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 Program { private static int[] Encrypt(int[] a, int k) { int[] res = new int[a.Length]; for(int i = 0; i < res.Length; i++) { unchecked { res[i] = a[i] + k; } } return res; } private static int[] Decrypt(int[] a, int k) { return Encrypt(a, -k); } private const int KEY = 123456789; public static void Main(string[] args) { int[] a1 = { int.MinValue, -1, 0, 1, int.MaxValue }; int[] a2 = Encrypt(a1, KEY); int[] a3 = Decrypt(a2, KEY); for(int i = 0; i < a1.Length; i++) { Console.WriteLine("{0} -> {1} -> {2}", a1[i], a2[i], a3[i]); } } } }