如何加密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. RSACryptoServiceProvider和Web.config加密
- 3. Web.config密碼加密
- 4. 解密web.config中
- 5. 加密和解密
- 6. 加密和解密
- 7. 加密和解密
- 8. 加密和解密
- 9. 加密和解密密碼
- 10. 加密Web.Config中
- 11. 如何在c#中的connectionStrings Web.config/App.config中只加密和解密密碼?
- 12. C#(加密)和Java(解密)之間的AES加密/解密
- 13. 加密Web.config Windows Azure
- 14. 加密web.config部分
- 15. 加密web.config文件
- 16. 加密Web.config部分
- 17. VB.NET加密和解密
- 18. 加密和解密在iphonesdk
- 19. C#加密和解密
- 20. 加密和解密文件
- 21. PHP加密和VB.net解密
- 22. 加密和解密餅乾
- 23. 加密和解密IP
- 24. 加密和解密對象
- 25. php加密和解密
- 26. Android - 加密和解密
- 27. Android AES加密和解密
- 28. PGP加密和解密
- 29. ESAPI加密和解密
- 30. 文件加密和解密
你想加密孔配置還是隻加密連接字符串? – 2011-03-16 14:28:15