public void EncryptAndDecryptEmptyString() { var plainText = string.Empty; var key = L64.GenerateKey(); var cipherText = L64.Encrypt(plainText, key); var decrypted = L64.Decrypt(cipherText, key); Assert.That(plainText, Is.EqualTo(cipherText)); Assert.That(plainText, Is.EqualTo(decrypted)); }
public void FailToDecryptWithWrongKey() { var plainText = "Foo Bar"; var key = L64.GenerateKey(); var invalidKey = L64.GenerateKey(); Assert.That(key, Is.Not.EqualTo(invalidKey)); var cipherText = L64.Encrypt(plainText, key); var decrypted = L64.Decrypt(cipherText, invalidKey).Trim(); Assert.That(plainText, Is.Not.EqualTo(decrypted)); }
public void EncryptAndDecryptSimpleString() { var plainText = "Hello, World!"; var key = L64.GenerateKey(); var cipherText = L64.Encrypt(plainText, key); var decrypted = L64.Decrypt(cipherText, key).Trim(); Assert.That(plainText, Is.Not.EqualTo(cipherText)); Assert.That(plainText, Is.Not.SameAs(cipherText)); Assert.That(plainText, Is.EqualTo(decrypted)); Assert.That(plainText, Is.Not.SameAs(decrypted)); Assert.That(decrypted, Is.Not.EqualTo(cipherText)); Assert.That(decrypted, Is.Not.SameAs(cipherText)); }
public void RejectInvalidTexts() { Assert.That(() => L64.Encrypt(null, null), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("plaintext")); Assert.That(() => L64.Decrypt(null, null), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("ciphertext")); }