예제 #1
0
                    public void ThenReturnFalse(string encrypted)
                    {
                        var result =
                            new AESEncryptorService(TestKey).TryDecrypt(encrypted, out var decryptedValue);

                        result.ShouldBeFalse(decryptedValue);
                    }
예제 #2
0
                    public void ThenItShouldEncryptTheValueAndAppendSignature(string input, string encrypted)
                    {
                        var result = new AESEncryptorService(TestKey).TryDecrypt(
                            encrypted, out var decrypted);

                        result.ShouldBeTrue();
                        decrypted.ShouldBe(input);
                    }
예제 #3
0
            public void ThenEncryptDecryptWorkTogetherSuccessfully()
            {
                var input = "What’s in a name? A rose by any other name would smell as sweet.";

                var service = new AESEncryptorService(TestKey);

                var encrypted = service.Encrypt(input);

                var result = service.TryDecrypt(encrypted, out string decrypted);

                result.ShouldBeTrue();
                decrypted.ShouldBe(input);
            }
예제 #4
0
                    public void ThenTheWrongValueIsDecrypted()
                    {
                        // If someone gets hold of the key and is thus able to re-sign contents then a modified IV
                        // will cause the decrypted value to be incorrect - but there's no way to know in code.
                        // Of course if they have the key then they're in the clear anyway! Only preserving
                        // this test to acknowledge how the mechanism works.

                        var result =
                            new AESEncryptorService(TestKey).TryDecrypt(
                                EncryptMeTamperedIvResigned, out var decryptedValue);

                        result.ShouldBeTrue();
                        decryptedValue.ShouldNotBe(EncryptMe);
                    }
예제 #5
0
                public void ThenItShouldEncryptTheValueAndAppendSignature(string input, string expected)
                {
                    var result = new AESEncryptorService(TestKey, TestIv).Encrypt(input);

                    result.ShouldBe(expected);
                }