public void Can_Round_Trip_Protection()
        {
            if (!didSetup)
            {
                Setup();
            }

            Assert.NotNull(persistentProtector);

            string clearText     = "Mozart was a fine violin player and composer";
            string protectedText = persistentProtector.Protect(clearText);

            string unprotectedText = persistentProtector.Unprotect(protectedText);

            Assert.True(clearText == unprotectedText);
        }
Beispiel #2
0
        public static string PersistentProtect(
            this IPersistedDataProtector dp,
            string clearText)
        {
            byte[] clearBytes     = Encoding.UTF8.GetBytes(clearText);
            byte[] protectedBytes = dp.Protect(clearBytes);

            string result = Convert.ToBase64String(protectedBytes);

            return(result);
        }