Beispiel #1
0
            public void HappyPath_EncryptAndThenDecrypt(string value)
            {
                var e = new Encrypt {
                    PublicKey = publicKey, PrivateKey = privateKey
                };

                WrappedValue wrapped = e.EncryptAndWrap(value);

                Assert.NotNull(wrapped);
                Assert.NotNull(wrapped.EncryptedAESKey);
                Assert.NotNull(wrapped.IV);
                Assert.NotNull(wrapped.EncryptedValue);

                string wrapHexed = wrapped.ToString();

                Assert.NotNull(wrapHexed);
                Assert.NotEqual(string.Empty, wrapHexed);

                WrappedValue unhexedWrap = null;

                try
                {
                    unhexedWrap = new WrappedValue(wrapHexed);
                }
                catch
                {
                    // no-op
                }

                Assert.NotNull(unhexedWrap);
                Assert.Equal(wrapped.EncryptedValue, unhexedWrap.EncryptedValue);

                string decryptedValue = e.UnwrapAndDecrypt(unhexedWrap);

                Assert.NotNull(decryptedValue);
                Assert.Equal(value, decryptedValue);
            }
Beispiel #2
0
 public override string ToString()
 {
     return(WrappedValue.ToString());
 }
Beispiel #3
0
 public override string ToString()
 {
     return(WrappedValue?.ToString() ?? "");
 }