C#配置文件加密

来源:互联网 发布:centos7 bugzilla端口 编辑:程序博客网 时间:2024/06/14 07:28


将app.config 改成 web.config


以管理员的身份运行 VS 开发人员命令提示


  aspnet_regiis.exe -pef "配置节" "项目路径"


例如:

aspnet_regiis.exe -pef "connectionStrings" "C:\myweb\HelloService" -prov "DataProtectionConfigurationProvider"


aspnet_regiis.exe -pef "appSettings" "C:\myweb\HelloService" -prov "DataProtectionConfigurationProvider"


加密配置文件后,源程序不需要做任何改动。如果要修改或添加新的配置信息,需要先解密配置文件。不论使用哪种Provider,都只能在进行加密的计算机上对配置文件进行解密。


解密

aspnet_regiis.exe -pdf "connectionStrings" "C:\myweb\HelloService"


aspnet_regiis.exe -pdf "appSettings" "C:\myweb\HelloService"

0 0
原创粉丝点击