public void ProtectDataRoundTrips()
        {
            var provider         = ServiceProvider.GetRequiredService <IDataProtectionProvider>();
            var prototector      = provider.CreateProtector("test");
            var secureDataFormat = new SecureDataFormat <string>(new StringSerializer(), prototector);

            string input         = "abcdefghijklmnopqrstuvwxyz0123456789";
            var    protectedData = secureDataFormat.Protect(input);
            var    result        = secureDataFormat.Unprotect(protectedData);

            Assert.Equal(input, result);
        }
        public void UnprotectWithDifferentPurposeFails()
        {
            var provider         = ServiceProvider.GetRequiredService <IDataProtectionProvider>();
            var prototector      = provider.CreateProtector("test");
            var secureDataFormat = new SecureDataFormat <string>(new StringSerializer(), prototector);

            string input         = "abcdefghijklmnopqrstuvwxyz0123456789";
            string purpose       = "purpose1";
            var    protectedData = secureDataFormat.Protect(input, purpose);
            var    result        = secureDataFormat.Unprotect(protectedData); // Null other purpose

            Assert.Null(result);

            result = secureDataFormat.Unprotect(protectedData, "purpose2");
            Assert.Null(result);
        }