MSDN学习: 加密解密Config文件中的Sections( Encrypting and Decrypting Configuration Sections)

https://msdn.microsoft.com/en-us/library/wfc2t3az(v=vs.100).aspx

https://msdn.microsoft.com/en-us/library/zhhddkxy(v=vs.100).aspx

需要使用administrator权限run cmd

Cd /d C:\Windows\Microsoft.NET\Framework64\v4.0.30319

加密

aspnet_regiis -pef connectionStrings D:\test

解密

aspnet_regiis -pdf connectionStrings D:\test

加密

aspnet_regiis -pef "connectionStrings" "D:\test" -prov "DataProtectionConfigurationProvider"

解密

aspnet_regiis -pdf connectionStrings D:\test

配置MyProvider

<configProtectedData>

<providers>

<add name="MyProvider"

type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"

keyContainerName="MyKeys"

useMachineContainer="true" />

</providers>

</configProtectedData>

生成MyKeys

aspnet_regiis -pc "MyKeys" –exp

加密

aspnet_regiis -pef "connectionStrings" "D:\test" -prov "MyProvider"

解密

aspnet_regiis -pdf connectionStrings D:\test

导出keys

aspnet_regiis -px "MyKeys" "d:\test\keys.xml" –pri

导入keys

aspnet_regiis -pi "MyKeys" "d:\test\keys.xml"

上一篇:CentOs 自带 PHP 之坑


下一篇:iOS · 安装RVM cocoaPods 及问题解决