winform 配置文件的加密解密


 

winform 配置文件的加密解密
Visual Studio 命令提示(2010) 窗口下直接輸入 :
解密
aspnet_regiis -pdf connectionStrings 程序文件夾全目錄


加密
aspnet_regiis -pef connectionStrings 程序文件夾全目錄

注意:加密解密過程中必須把配置文件名稱改為web.config
程序運行一定要改回來App.cong

也可以通過運行CMD切換到命令提示符下,進入到C:\WINDOWS\Microsoft.net\Framework\v2.0.xxxx下,
其中 xxxx 是你所用的Framework版本,可以通過打開上述目錄得到。
=================================================


配置文件:加密前
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="str1" connectionString="data source=127.0.0.1;database=CustomerServiceDB;
uid=sa;pwd=123" />
</connectionStrings>
</configuration>
===================================
配置文件:加密后
===================================

   
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>

<CipherValue>UqupaYVDA7WOWEWwG1foftuhquDgLMkmgGQbDGceawbDOQzjdRQzRU9/tyr1GT0qHnAP5tAm/2PO1SaFQ
EHva6a3yVUaDdHjXYdpNx5YiI0O5sXssWZCRE7kwFPHKoK6RsIMEqjgVDFEkWFhwgjDUsIiL1TURpMcCL6HfPtP
+ns=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>w9cu5AenHpo4oAVZYogic3CY9nQDFkutN4OAxYnmP/iBFfwdqBBJav/h7pGUrN+
+gWjT9t9IBkTWlLKd0/mEB2IIdmuvwEDLywxNZvPacbyzRI1tLlKf6oD0VLkkEqxgHD6Vh+AaM
+zypwKttzKRrAIt6uxxOzinz7cLWXEZwYfmX+ZZ7+ob8hbh0rW0Ehn2bq4DjhysROW98DPublmnJw==</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
</configuration>
====================================================================================


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM