コード例 #1
0
        public void FourSquare()
        {
            FourSquareCipher cipher = new FourSquareCipher();

            char[, ][,] key =
            {
                { PolybiusSquare.CreateFromString(Charsets.EnglishWithoutQ), PolybiusSquare.CreateFromKeyword("KEYWORD", Charsets.EnglishWithoutQ)                                 },
                { PolybiusSquare.CreateFromKeyword("EXAMPLE",                Charsets.EnglishWithoutQ),                  PolybiusSquare.CreateFromString(Charsets.EnglishWithoutQ) }
            };

            const string plaintext  = "Help me Obiwan Kenobi";
            const string ciphertext = "Fygm ky Hobxmf Kkkimd";

            Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext, key));
            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, key));
        }
コード例 #2
0
        public void TwoSquare()
        {
            TwoSquareCipher cipher = new TwoSquareCipher();

            char[][,] key =
            {
                PolybiusSquare.CreateFromKeyword("EXAMPLE", Charsets.EnglishWithoutQ),
                PolybiusSquare.CreateFromKeyword("KEYWORD", Charsets.EnglishWithoutQ)
            };

            const string plaintext  = "Help me Obiwan Kenobi";
            const string ciphertext = "Hedl xw Sdjyan Hotkdg";

            Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext, key));
            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, key));
        }