Example #1
0
        public void MultiplePermutationCipherShouldWorkCorrectlyForHugePhrases()
        {
            //first
            string text = "SP.NET Core определяется кроссплатформенностью, то есть он" +
                          " работает на Mac OS X, так же как на Linux и Windows. ";
            var   multiplePermutationCipher = new MultiplePermutationCipher();
            int   amountOfColumns           = 8;
            Table table         = new Table(text, amountOfColumns);
            var   key           = multiplePermutationCipher.CreatePermutationNumbers(table);
            var   encryptedText = multiplePermutationCipher.Encrypt(table, key);

            table = new Table(encryptedText, amountOfColumns);
            var decryptedText = multiplePermutationCipher.Decrypt(table, key);

            Assert.AreEqual(decryptedText.Substring(0, text.Length), text);

            //second
            text = "Это позволит вам запускать команды, включая dotnet restore и любые " +
                   "другие команды, определенные в project.json, а также пользовательские " +
                   "задачи из .vscode/tasks.json, напрямую из Visual Studio Code.";
            amountOfColumns = 12;
            table           = new Table(text, amountOfColumns);
            key             = multiplePermutationCipher.CreatePermutationNumbers(table);
            encryptedText   = multiplePermutationCipher.Encrypt(table, key);
            table           = new Table(encryptedText, amountOfColumns);
            decryptedText   = multiplePermutationCipher.Decrypt(table, key);

            Assert.AreEqual(decryptedText.Substring(0, text.Length), text);

            //third
            text = "В терминале/командной строке запустите dotnet restore, чтобы " +
                   "восстановить зависимости проекта. Как вариант, вы можете нажать " +
                   "command shift p в Visual Studio Code, а затем набрать dot";
            amountOfColumns = 15;
            table           = new Table(text, amountOfColumns);
            key             = multiplePermutationCipher.CreatePermutationNumbers(table);
            encryptedText   = multiplePermutationCipher.Encrypt(table, key);
            table           = new Table(encryptedText, amountOfColumns);
            decryptedText   = multiplePermutationCipher.Decrypt(table, key);

            Assert.AreEqual(decryptedText.Substring(0, text.Length), text);
        }
Example #2
0
        public void MultiplePermutationCipherShouldWorkCorrectlyForSmallPhrases()
        {
            string text = "Рядки тастовбці";
            var    multiplePermutationCipher = new MultiplePermutationCipher();
            int    amountOfColumns           = 4;
            Table  table = new Table(text, amountOfColumns);
            var    key   = new Tuple <List <int>, List <int> >(new List <int>()
            {
                3, 0, 1, 2
            }, new List <int>()
            {
                2, 0, 3, 1
            });
            var encryptedText = multiplePermutationCipher.Encrypt(table, key);

            table = new Table(encryptedText, amountOfColumns);
            var decryptedText = multiplePermutationCipher.Decrypt(table, key);

            Assert.AreEqual(encryptedText, " аиттвсоц біякРд");
            Assert.AreEqual(decryptedText.Substring(0, text.Length), text);
        }