当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - ConfigurationSection Get XmlDocument for encrypt/decrypt

问题描述:

I'm using C#.

I have XML configuration file that i'm loaded as follow:

 ExeConfigurationFileMap configFileMap =

new ExeConfigurationFileMap();

configFileMap.ExeConfigFilename = myXMLFilePath;

// Get the mapped configuration file

System.Configuration.Configuration config =

ConfigurationManager.OpenMappedExeConfiguration(

configFileMap, ConfigurationUserLevel.None);

// loads configurations

myConfigureObject = (MyConfigureClass)config.GetSection(mySectionName);

I have at my .xml file elements that i'm encrypt with https://msdn.microsoft.com/en-us/library/system.security.cryptography.xml.encrypteddata(v=vs.110).aspx

Now, lets assume that my .xml configuration file already encrypted.

How can i get the "inner xml"/xmlDoc of my .xml configuration file and to decrypt the elements before i'm loaded the sections?

I know how to decrypt the elements i just need to know how to get the xmlDocument object

I.e

ExeConfigurationFileMap configFileMap =

new ExeConfigurationFileMap();

configFileMap.ExeConfigFilename = myXMLFilePath;

// Get the mapped configuration file

System.Configuration.Configuration config =

ConfigurationManager.OpenMappedExeConfiguration(

configFileMap, ConfigurationUserLevel.None);

//Decrypt Data

XmlDocument xmlDoc = config.GetXmlDocument();//???

XmlDeceypt(xmlDoc);//How can i get the xmlDoc??

// loads configurations

myConfigureObject = (MyConfigureClass)config.GetSection(mySectionName);

Thanks.

分享给朋友:
您可能感兴趣的文章:
随机阅读: