Пример #1
0
        public void RoundTripPrivate()
        {
            const string payload   = "Love is stronger than hate or fear";
            string       encrypted = PasetoUtility.EncryptBytes(_symmetricKey, Encoding.UTF8.GetBytes(payload), nonce: new byte[24]);

            Assert.Equal(payload, Encoding.UTF8.GetString(PasetoUtility.DecryptBytes(_symmetricKey, encrypted).Payload));
        }
Пример #2
0
        public void FooterCanBeParsed()
        {
            string footerText = "Hello friend";

            Assert.Equal(footerText, PasetoUtility.ParseFooter(PasetoUtility.EncryptBytes(_symmetricKey, new byte[0], footerText)));

            var footerJson = new Dictionary <string, object> {
                ["hello"] = "friend"
            };

            Assert.Equal(footerJson, PasetoUtility.ParseFooterJson(PasetoUtility.Encrypt(_symmetricKey, new PasetoInstance {
                Footer = footerJson
            })));
        }
Пример #3
0
        public void Encrypt(string payload, string message, string footer = "")
        {
            var nonce = new byte[24];

            Assert.Equal(message, PasetoUtility.EncryptBytes(_symmetricKey, Encoding.UTF8.GetBytes(payload), footer, nonce));
        }
Пример #4
0
 public void EncryptWithNullKey(string payload, string message)
 {
     Assert.Equal(message, PasetoUtility.EncryptBytes(new byte[32], Encoding.UTF8.GetBytes(payload), nonce: new byte[24]));
 }