Exemplo n.º 1
0
        /// <summary>
        /// Writes an AES 256 encrypted value to its configuration file.
        /// </summary>
        /// <param name="value">The value to write to the file.</param>
        /// <param name="log">The event log to log execptions to. May be null for no logging.</param>
        /// <returns>True if the write was successful, false otherwise.</returns>
        protected bool SecureWrite(string value, EventLog.EventLog log)
        {
            // Create a consolidated encrypted string value for storage in the file.
            string consolidatedString = AES256.CreateConsolidatedString(value);

            // Check that the consolidated string value was created successfully.
            if (!string.IsNullOrWhiteSpace(consolidatedString))
            {
                // The consolidated string value was created successfully.

                // Write the consolidated string value containing the encrypted value to a file.
                return(Write(consolidatedString, log));
            }
            else
            {
                // The consolidated string value was not created.
                return(false);
            }
        }