Example #1
0
        public void DecryptBlockDecryptsBlockBackToOriginalPlainText()
        {
            const string originalMessage = "This is my message to encrypt.";

            string encrypted = BlockEncrypter.EncryptBlock(originalMessage, Encoding.ASCII.GetBytes("Pa55w0rd"));
            string decrypted = BlockEncrypter.DecryptBlock(encrypted, Encoding.ASCII.GetBytes("Pa55w0rd"));

            Assert.AreEqual(originalMessage, decrypted);
        }
        private void DecryptText()
        {
            SetPasswordAndStatusBar(false);

            try
            {
                decryptedText.Text = BlockEncrypter.DecryptBlock(textToDecrypt.Text, _passwordEntry.Password.CombinedPasswords);
            }
            catch (CryptographicException ex)
            {
                decryptedText.Text = "";
                MessageBox.Show(ex.Message, Resources.TextShredderMainForm_DecryptText_Message_Tamper_Alert, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            catch (Exception)
            {
                decryptedText.Text = "";
                MessageBox.Show(Resources.TextShredderMainForm_DecryptText_There_was_an_error_decrypting_the_message_, Resources.TextShredderMainForm_DecryptText_Decryption_Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #3
0
 public void DecryptBlockThrowsArgumentNullExceptionIfPasswordIsNull()
 {
     BlockEncrypter.DecryptBlock("blah blah blah blah blah blah", null);
 }
Example #4
0
 public void DecryptBlockThrowsArgumentNullExceptionIfTextToDecryptIsNull()
 {
     BlockEncrypter.DecryptBlock(null, null);
 }