log4net 对配置的ConnectionString 进行加密

下载源码log4net

在AdoNetAppender.cs 文件下的m_dbConnection.ConnectionString = m_connectionString 进行解密的函数如:加密config一样

 

// Set the connection string
                ShareSafePassword.CRM log4safe = new ShareSafePassword.CRM (); //解密类
                if (m_connectionString != null && m_connectionString != "")
                {
                    m_connectionString = log4safe.DecrypWebConfig(m_connectionString);//实现解密
                }
               
    m_dbConnection.ConnectionString = m_connectionString;

    using(SecurityContext.Impersonate(this))
    {
     // Open the database connection
     m_dbConnection.Open();
    }

即可实现将配置log4net的配置节点的敏感数据进行加密

你可能感兴趣的:(Connection)