public void Decrypting_data_that_could_not_possibly_be_encrypted_by_pass_should_return_null() { /* Arrange */ byte[] sourceTooSmall = new byte[4]; var crypto = new TestCryptoProviderWithPass("testingisawesome"); /* Act */ bool isEncrypted = crypto.IsEncrypted(sourceTooSmall); var decryptedVale = crypto.Decrypt(sourceTooSmall); /* Assert */ decryptedVale.Should().BeNull(); isEncrypted.Should().BeFalse(); }
public void Encrypting_and_decrypting_a_string_with_password_should_work() { /* Arrange */ string source = "SomeValue"; var crypto = new TestCryptoProviderWithPass { Password = "******", Iterations = 10, SaltBitSize = 128 }; /* Act */ string encryptedValue = crypto.Encrypt(source); bool isEncrypted = crypto.IsEncrypted(encryptedValue); string decryptedVale = crypto.Decrypt(encryptedValue); /* Assert */ encryptedValue.Should().NotBe(source); decryptedVale.Should().Be(source); isEncrypted.Should().BeTrue(); crypto.Password.Should().Be("testingisawesome"); crypto.Iterations.Should().Be(10); crypto.SaltBitSize.Should().Be(128); }