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)); }
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 }))); }
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)); }
public void EncryptWithNullKey(string payload, string message) { Assert.Equal(message, PasetoUtility.EncryptBytes(new byte[32], Encoding.UTF8.GetBytes(payload), nonce: new byte[24])); }