如何加密web.config文件? 然後我該如何解密它呢?web.config加密和解密
0
A
回答
1
問候qablan89我把你和你所需要的代碼是:
//Method for Encryption
public void EncryptConnectionString(Page Mypage)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection objConnectionString = (ConnectionStringsSection)objConfig.GetSection("connectionStrings");
if (!objConnectionString.SectionInformation.IsProtected)
{
objConnectionString.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
objConnectionString.SectionInformation.ForceSave = true;
objConfig.Save(ConfigurationSaveMode.Modified);
}
}
//Method for Decrypt
public void DecryptConnectionString(Page Mypage)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~);
ConnectionStringsSection objConnectionString = (ConnectionStringsSection)objConfig.GetSection("connectionStrings");
if (objConnectionString.SectionInformation.IsProtected)
{
objConnectionString.SectionInformation.UnprotectSection();
objConnectionString.SectionInformation.ForceSave = true;
objConfig.Save(ConfigurationSaveMode.Modified);
}
}
注意此代碼是,如果你指定另外一個我在這裏幫助
請在webconfig連接字符串屬性不要忘記爲你:)
問候
0
加密Web.config文件是一個預先正確的,如果它有用的答案標記第一次機會tty壞想法。
你肯定喜歡存儲連接字符串敏感信息,但是......
- 沒有用戶可以從HTTP
- 使用加密來保護信息從所有不必要的眼睛下載Web.config文件。既然你已經對HTTP客戶端的保護,唯一的一個(或多個)能夠讀取它是Web服務器和服務器管理員
當然服務器需要了解的Web.config,所以假如你希望它加密你必須給服務器的關鍵。
但後來因爲管理員(如果它不是你自己)具有控制權的服務器,他擁有控制權的Web.config :)
簡單。
相關問題
- 1. 加密/解密web.config
- 2. 加密和解密
- 3. 加密和解密
- 4. 加密和解密
- 5. 加密和解密
- 6. 加密Web.Config中
- 7. C#(加密)和Java(解密)之間的AES加密/解密
- 8. Android - 加密和解密
- 9. 加密和解密與diarrits
- 10. Android - 加密和解密
- 11. PGP加密和解密
- 12. c#加密和解密
- 13. ESAPI加密和解密
- 14. 加密和解密md5
- 15. 加密和解密文件
- 16. PHP加密和VB.net解密
- 17. ActionScript3和Java加密/解密
- 18. gpg加密和解密
- 19. 加密和解密在iphonesdk
- 20. 文件加密和解密
- 21. 加密web.config文件
- 22. 加密Web.config部分
- 23. 加密Web.config Windows Azure
- 24. pycrypto加密/解密,解密
- 25. 解密 - 加密加密JS
- 26. 使用Jasypt加密和解密密碼
- 27. 用密鑰加密和解密數據
- 28. 試圖加密和解密vigenere密碼
- 29. 加密和解密密碼的WebSphere
- 30. 僅加密web.config中的密碼ASP.NET
你想加密孔配置還是隻加密連接字符串? – 2011-03-16 14:28:15