Esempio n. 1
0
        private string ReadFieldValue(
            XmlReader reader, out bool isProtected)
        {
            isProtected = IsProtected(reader);
            reader.MoveToContent();
            var value = reader.ReadElementContentAsString();

            if (isProtected && !string.IsNullOrEmpty(value))
            {
                value = _crypto.Decrypt(value);
            }

            return(value);
        }
Esempio n. 2
0
        /// <summary>
        /// Decrypts the protected fields.
        /// </summary>
        /// <param name="crypto">The crypto random stream.</param>
        public void Decrypt(CryptoRandomStream crypto)
        {
            if (crypto == null)
            {
                throw new ArgumentNullException("crypto");
            }

            var values = GetProtectedValues();

            foreach (var item in values)
            {
                item.Value = crypto
                             .Decrypt(item.Value);
            }
        }