#region using System; using System.Linq; using OpenMetaverse; #endregion namespace AtBash { internal class Program { private static void Main(string[] args) { // Prints out "Hello there! Good day!" on the console. Console.WriteLine(wasATBASH("Svool gsviv! Tllw wzb!")); Console.ReadKey(); } /////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// /// /// An implementation of the ATBASH cypher for latin alphabets. /// /// the data to encrypt or decrypt /// the encrypted or decrypted data private static string wasATBASH(string data) { char[] a = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; char[] input = data.ToArray(); Parallel.ForEach(Enumerable.Range(0, data.Length), i => { char e = input[i]; if (!char.IsLetter(e)) return; int x = 25 - Array.BinarySearch(a, char.ToLowerInvariant(e)); if (!char.IsUpper(e)) { input[i] = a[x]; return; } input[i] = char.ToUpperInvariant(a[x]); }); return new string(input); } } }