public void EncodingsFailWhenDifferent() { var aesStringEncryptor = new AESStringEncryptor(Password, Salt, Encoding.UTF32); string encryptedText = aesStringEncryptor.EncryptString(Plaintext); Assert.NotEqual(Plaintext, encryptedText); var aesStringDecryptor = new AESStringEncryptor(Password, Salt, Encoding.UTF8); Assert.Throws <CryptographicException>(() => aesStringDecryptor.DecryptString(encryptedText)); }
public void EncryptionAndDecryptionWithWrongSaltFails() { var aes = new AESStringEncryptor(Password, Salt); string encryptedText = aes.EncryptString(Plaintext); Assert.NotEqual(Plaintext, encryptedText); var badAes = new AESStringEncryptor(Password, Salt.ToLowerInvariant()); Assert.Throws <CryptographicException>(() => badAes.DecryptString(encryptedText)); }
public void EncryptionAndDecryptionWorkCorrectly() { var aesStringEncryptor = new AESStringEncryptor(Password, Salt); string encryptedText = aesStringEncryptor.EncryptString(Plaintext); Assert.NotEqual(Plaintext, encryptedText); var aesStringDecryptor = new AESStringEncryptor(Password, Salt); string decryptedText = aesStringDecryptor.DecryptString(encryptedText); Assert.Equal(Plaintext, decryptedText); }
public void EncodingsWorkWhenSame() { var aesStringEncryptor = new AESStringEncryptor(Password, Salt, Encoding.ASCII); string encryptedText = aesStringEncryptor.EncryptString(Plaintext); Assert.NotEqual(Plaintext, encryptedText); var aesStringDecryptor = new AESStringEncryptor(Password, Salt, Encoding.ASCII); string decryptedText = aesStringDecryptor.DecryptString(encryptedText); Assert.Equal(Plaintext, decryptedText); }