Encrypt connection string in Web.config

How to Encryption and Decryption connection string in Web.config ? Explain with Example ?

Questions by rajankvns   answers by rajankvns

Showing Answers 1 - 3 of 3 Answers

Sudhakar

  • Apr 4th, 2012
 

You can use server.EncryptUrl , Server.DecryptUrl Functions.

rupinder

  • Apr 17th, 2013
 


methods for Encrypting and decrypting connectionStrings
section in web.config
you can use encryption configuration model " Rsa,"
it is feasible to change this to DataProtectionConfigurationProvider

Code
  1. using System;

  2. using System.Collections.Generic;

  3. using System.Text;

  4. using System.Web;

  5. //specific to configuration

  6. using System.Configuration;

  7. using System.Web.Configuration;

  8. using System.Web.Security;

  9. namespace WebUtils

  10. {

  11. /// <summary>

  12. /// Contains methods for Encrypting and decrypting connectionStrings

  13. /// section in web.config

  14. /// current encryption configuration model is Rsa,

  15. /// it is feasible to change this to DataProtectionConfigurationProvider

  16. /// </summary>

  17. public class EncryptDecrypt

  18. {

  19. //Get Application path using HttpContext #region Encrypt method

  20. "connectionStrings""RsaProtectedConfigurationProvider");

  21. config.Save();

  22. }

  23. } #endregi

  24. #region Decrypt method

  25. "connectionStrings"#endregion

  26. }

  27. }

  28.  

  Was this answer useful?  Yes

Rodger Svovah

  • May 25th, 2014
 

You encrypt connection string string by using aspnet_regiis.exe like so:
aspnet_regiis.ex -pe "connection string" -app "MyWebApp"

To decrypt you only need to change the option -pe to -pd.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions