示例#1
0
        public void ViewStateEncryptedTest()
        {
            string obj    = "test value";
            var    secret = StorageImplementation.GetSecret("Key");
            Func <byte[], byte[]> filter = x => Crypt.Encrypt(secret, x);
            var viewstate = StorageImplementation.ViewState(obj, filter);
            var encrypted = Convert.FromBase64String(viewstate);
            var bytes     = Crypt.Decrypt(secret, encrypted);
            var copy      = (string)Serialization.Deserialize(bytes);

            Serialization.Deserialize(bytes);
            Assert.That(copy, Is.EqualTo("test value"));
        }
        public void ViewStateEncryptedTest()
        {
            this.TestProperty = "test value";
            var secret = StorageImplementation.GetSecret("Key");
            Func <byte[], byte[]> filter = x => Crypt.Encrypt(secret, x);
            var viewstate = this.ViewState(filter);
            var fields    = viewstate.Split(":");
            var encrypted = Convert.FromBase64String(fields[1]);
            var bytes     = Crypt.Decrypt(secret, encrypted);
            var copy      = (PersistentControllerExtensionTest)Serialization.Deserialize(bytes);

            Serialization.Deserialize(bytes);
            Assert.That(copy.TestProperty, Is.EqualTo("test value"));
        }