Esempio n. 1
0
        static void Main(string[] args)
        {
            var startString =
                "A Cardan grille is made from a sheet of fairly rigid paper or parchment, or from thin metal. The paper is ruled to represent lines of handwriting and rectangular areas are cut out at arbitrary intervals between these lines.\r\n\r\nAn encipherer places the grille on a sheet of paper and writes his message in the rectangular apertures, some of which might allow a single letter, a syllable, or a whole word. Then, removing the grille, the fragments are filled out to create a note or letter that disguises the true message. Cardano suggested drafting the text three times in order to smooth any irregularities that might indicate the hidden words.";
            string text = File.ReadAllText(@"C:\Users\user\source\repos\Cryptology\Cryptology\Texts\text.txt");
            //var cypher = new CaeserCipher(text, 1);
            var cypher = new AffineCipher(text, 3, 4);

            Console.WriteLine("Encoded text:");
            var encryptedText = cypher.Encrypt();

            Console.WriteLine(encryptedText);
            File.WriteAllText(@"C:\Users\user\source\repos\Cryptology\Cryptology\Texts\textEncrypted.txt", encryptedText);


            Console.WriteLine("\nDecrypted text:");
            var decryptedText = cypher.Decrypt();

            Console.WriteLine(decryptedText);
            File.WriteAllText(@"C:\Users\user\source\repos\Cryptology\Cryptology\Texts\textDecrypted.txt", decryptedText);

            Console.WriteLine("\nDecoded text:");
            var decodedText = cypher.Decode();

            Console.WriteLine(decodedText);
            File.WriteAllText(@"C:\Users\user\source\repos\Cryptology\Cryptology\Texts\textDecoded.txt", decodedText);
            Console.ReadKey();
        }
Esempio n. 2
0
 public void Decode_with_too_many_spaces()
 {
     Assert.Equal("jollygreengiant", AffineCipher.Decode("vszzm    cly   yd cg    qdp", 15, 16));
 }
Esempio n. 3
0
 public void Decode_with_a_not_coprime_to_m()
 {
     Assert.Throws <ArgumentException>(() => AffineCipher.Decode("Test", 13, 5));
 }
Esempio n. 4
0
 public void Decode_with_no_spaces_in_input()
 {
     Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AffineCipher.Decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33));
 }
Esempio n. 5
0
 public void Decode_all_the_letters()
 {
     Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AffineCipher.Decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33));
 }
Esempio n. 6
0
 public void Decode_numbers()
 {
     Assert.Equal("testing123testing", AffineCipher.Decode("odpoz ub123 odpoz ub", 25, 7));
 }
Esempio n. 7
0
 public void Decode_a_sentence()
 {
     Assert.Equal("anobstacleisoftenasteppingstone", AffineCipher.Decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16));
 }
Esempio n. 8
0
 public void Decode_exercism()
 {
     Assert.Equal("exercism", AffineCipher.Decode("tytgn fjr", 3, 7));
 }