我希望保护我的应用程序设置中的一个键/值对,但不保护其他键/值对,使用之前使用的ProtectSection方法来实现,如下所示。
var configurationSection = config.GetSection("appSettings");
configurationSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
理想情况下,我希望能够像下面这样做:
var configurationElement = config.GetSection("appSettings").GetElement("Protected");
configurationElement.ElementInformation.ProtectElement("DataProtectionConfigurationProvider");
这里是我将要操作的示例appSettings:
<configuration>
<appSettings>
<add key="Unprotected" value="ChangeMeFreely" />
<add key="Protected" value="########"/>
</appSettings>
</configuration>
我一直在搜索,但没有找到实现这个目标的方法。这个可行吗?