Esempio n. 1
0
        public void Security_Cryptography_CaesarEncryptor()
        {
            var TestItem        = new CaesarEncryptor();
            var encryptedString = TestItem.Encrypt("Test");

            Assert.IsTrue(encryptedString == "bQB%2BAIwAjQA%3D");
            var decryptedString = TestItem.Decrypt(encryptedString);

            Assert.IsTrue(decryptedString == "Test");
        }
Esempio n. 2
0
        private void Encrypt(string alph, int shift)
        {
            ExpandForm(NormalFormHeight);

            string text      = inputText.Text;
            var    encryptor = new CaesarEncryptor(alph, shift);

            try
            {
                resultEncText.Text = encryptor.Encrypt(text);
                resultDecText.Text = encryptor.Decrypt(resultEncText.Text);
            }
            catch (KeyNotFoundException)
            {
                MessageBox.Show(
                    Resources.MainForm_Encrypt_Some_letters_aren_t_from_the_current_alphabet,
                    Resources.MainForm_Encrypt_Wrong_text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
        }