/// <summary> /// Retrieves an AES 256 encrypted value from the configuration file. /// </summary> /// <param name="log">The event log to log exceptions to. May be null for no logging.</param> /// <returns>The value or null if not found or it could not be decrypted.</returns> protected string SecureGet(EventLog.EventLog log) { // Get the raw value of the encrypted string. string value = Get(log); // Decrypt the string if the raw value contains one. if (!string.IsNullOrWhiteSpace(value)) { // Get the encrypted string containing the key, initialization vector, value, and key and // initialization vector lengths from the file. // Read only the first line of the file, as this is all that is necessary for the encrypted // format. StringReader reader = new StringReader(Get(log)); string encryptedValue = reader.ReadLine(); // Check that an encrypted value was retrieved. if (!string.IsNullOrWhiteSpace(encryptedValue)) { // The encrypted value was retrieved. // Decrypt the encrypted value. return(AES256.DecryptConsolidatedString(encryptedValue)); } } // Could not retrieve the encrypted value. return(null); }