cd C:WindowsMicrosoft.NETFrameworkv4.0.30319 ==在appSettings节点上添加== <configProtectedData> <providers> <add name="MyProvider" keyContainerName="自定义的密钥容器" useMachineContainer="true"
type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </configProtectedData> =========================== ===自定义key=== aspnet_regiis -pc "自定义密钥容器" -exp ===对key进行授权=== aspnet_regiis -pa "自定义密钥容器" "NT AUTHORITYNETWORK SERVICE" ===解决:返回错误信息:对象已存在=== aspnet_regiis -pa "NetFrameworkConfigurationKey" "域名账户" ===对指定物理路径下web.config指定的节点加密=== aspnet_regiis -pef "appSettings" "D:config" -prov "MyProvider" ===对指定物理路径下web.config指定的节点解密=== aspnet_regiis.exe -pef "appSettings" "d:/config/"
Net程序读取配置文件内容,无需做任何变动;会自动解密!
参考:https://msdn.microsoft.com/zh-cn/library/2w117ede(v=vs.100).aspx