This is a parallel implementation of the symmetric substitution cypher ATBASH in C#.


using System;
using System.Linq;
using OpenMetaverse;
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!"));
        //  Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3      //
        /// <summary>
        ///     An implementation of the ATBASH cypher for latin alphabets.
        /// </summary>
        /// <param name="data">the data to encrypt or decrypt</param>
        /// <returns>the encrypted or decrypted data</returns>
        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];
                input[i] = char.ToUpperInvariant(a[x]);
            return new string(input);

fuss/csharp/cryptography/cyphers/atbash.txt ยท Last modified: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p

For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.