public void CryptoEncryptString_Throws_Error_When_Password_Is_Null() { // Arrange Symmetric symmetric = new Symmetric(); password = null; // Act string encryptedString = symmetric.EncryptString(password, salt, encryptThis); }
public void CryptoEncryptString_Throws_Error_When_TextToEncrypt_Is_Empty_String() { // Arrange Symmetric symmetric = new Symmetric(); encryptThis = string.Empty; // Act string encryptedString = symmetric.EncryptString(password, salt, encryptThis); }
public void CryptoEncryptString_Throws_Error_When_Salt_Is_Null() { // Arrange Symmetric symmetric = new Symmetric(); salt = null; // Act string encryptedString = symmetric.EncryptString("bvgfiSdfr4)", salt, encryptThis); }
public void CryptoEncryptString_Encrypts_String() { // Arrange Symmetric symmetric = new Symmetric(); // Act string encryptedString = symmetric.EncryptString(password, salt, encryptThis); // Assert Assert.IsInstanceOfType(encryptedString, typeof(string)); Assert.AreNotEqual(encryptedString, encryptThis); }
public void WriteString(string data, bool withEncrypt = false, string algorithm = "AES", string password = "******") { using (FileStream fs = new FileStream(this.FileName, FileMode.OpenOrCreate, FileAccess.Write)) using (StreamWriter swr = new StreamWriter(fs)) { if (withEncrypt) { Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance(algorithm, password)); swr.Write(sym.EncryptString(data)); swr.Flush(); } else { swr.Write(data); swr.Flush(); } } }
private void btnEncryptRijndael_Click(object sender, EventArgs e) { Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance("Rijndael", "12345678")); txtEncrypted.Text = sym.EncryptString(txtPlainText.Text.Trim()); }
private void btnEncryptAES_Click(object sender, EventArgs e) { Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance("AES", "tumsakal_0963189366")); txtEncrypted.Text = sym.EncryptString(txtPlainText.Text.Trim()); }