public void DecryptTest() { // Arrange var pass = "******"; var pass2 = "This is a test key"; var subject = new StringEncryption(pass); var subject2 = new StringEncryption(pass2); var originalString = "Testing123!£$"; // Act var encryptedString1 = subject.Encrypt(originalString); var encryptedString2 = subject.Encrypt(originalString); var decryptedString1 = subject.Decrypt(encryptedString1); var decryptedString2 = subject.Decrypt(encryptedString2); var encryptedString3 = subject2.Encrypt(originalString); var encryptedString4 = subject2.Encrypt(originalString); var decryptedString3 = subject2.Decrypt(encryptedString3); var decryptedString4 = subject2.Decrypt(encryptedString4); // Assert Assert.AreEqual(originalString, decryptedString1, "Decrypted string should match original string"); Assert.AreEqual(originalString, decryptedString2, "Decrypted string should match original string"); Assert.AreEqual(originalString, decryptedString3, "Decrypted string should match original string"); Assert.AreEqual(originalString, decryptedString4, "Decrypted string should match original string"); }
private String doPossibleDecryption(String rdl) { if (Path.GetExtension(_SourceFile.LocalPath).Equals(".encrypted")) { try { StringEncryption enc = new StringEncryption(Prompt.ShowDialog("Please enter the passkey", "Passkey?")); rdl = enc.Decrypt(rdl); } catch (Exception) { MessageBox.Show(Properties.Resources.MDIChild_doPossibleDecryption_Incorrect_passkey_entered_); } } return rdl; }