asp.net - web.config encryption & decryption -


How can I encrypt a web.config file? And then how can I decrypt it again?

Greetings qablan89 I have found and you have the necessary code:

 < Code> // method for encryption Public Null Encryption Concession String (Page Mypage) {Configuration objConfig = WebConfigurationManager.OpenWebConfiguration ("~"); ConnectionStringsSection objConnectionString = (ConnectionStringsSection) objConfig.GetSection ("connectionStrings"); If (ObjConnectionString.StionInformation.Is protected) {objConnectionString.SectionInformation.ProtectSection ("RS-protected configuration provider"); ObjConnectionString.SectionInformation.ForceSave = true; ObjConfig.Save (ConfigurationSaveMode.Modified); }} / Decrypt public deformation decryptation string for the method {page mypage} {configuration objConfig = WebConfigurationManager.OpenWebConfiguration ("~); ConnectionStringsSection objConnectionString = objConfig.GetSection (" connectionStrings "); if (objConnectionString.SectionInformation.Is protected ) {ObjConnectionString.SectionInformation.UnprotectSection (); objConnectionString.SectionInformation.ForceSave = true objConfig.Save (ConfigurationSaveMode.Modified);}}   

Note This code is for connection string attribute in webconfig If you specify someone else, then here help me

Please do not forget to mark the correct answer, if it is useful for you :)

Regards

Comments