Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Wednesday, September 24, 2008

Encrypting and decrypting configuration sections in web.config


In Webapplication Configuration Section of Your Web Application Are Very Importent
Becuase it contain's your importent data like Connection Strings,Email id and Password
ect.. So We Need to Encrypt The Web.Config Perticular Section which contains
This Sensitive Information.it's can be done by following methods.

Encryption

Open your Visual 2005 Command Prompot and type Following Commands.

aspnet_regiis.exe -pe "appSettings
" -app  "/YourApplication Name"


So After Apply Encryption your App Setting Looks Like :-

< appSettings 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 > H9WkRu3BZi7mrEv1Rz50SuN1uHi64mBKAlZKaU2FpwOjMc8Sp1eFqGmi5N
UssOxJgJUwIzp4OXdKaypAuvLG2lCwjosIS+cZXqwTmFQ6wn8Zqs8HSRMCh38Hrg
h+/fp5M4GNijinuDhzdPXMDZrAokU17lLXttq7N+Cl37v+tVI= 
< /CipherValue >
                 < /CipherData >
             < /EncryptedKey >
         < /KeyInfo >
         < CipherData >
             < CipherValue > WurKXXIZzc4lpEfzTmTUAqw638D08i1PZKQzinRUsW52TdI4rEJrAZm6xVRtfVry
M3E81Pri9ZmxR/lXofJFRFDWG7KH4hIXkYZ12yTQ5YaQzuz6C/dtZ5IpSyNfTMzHE+hV0cZJVhe
2X5v5pXM1op5V4pjxGNJ5WpVXoXrvRFkIWDKNGjU9WY3BtL1HTUyzfZL61jrmg23hqPodH
B4z6oh1aUy27Sa46IZh+r+rbqlRgCusol+V06N7WcCRJhgfgfMNRKsGX12nDWJRZnWnF9kg
7ko2CK75xIa+keqaTwdoIyRf02+/Dhee3Sc2n+uBXWyHbPI8pK7CA69btzEIvxoudj7PIIse
LgE8Un8+HMQvpXylosO3A2FgzwjgUKN7dGVV9NElCAS+xfAO0YdXY/mRaWi3eB8DTnKGtVNId7
hTBJddT01GCg8eBgX5NXqg173yXg3N5+P1a3+X00Szxo9JqasJmAfszFMR1aCSjxBnZJcMxSIn
ssBwV0w2VH4IhjKxbcORPzMsp01++41zpO9LJlpH27ZKZWhZt3GGPmBjZD/pmrPrKdLOIJiJfPbG < /CipherValue >
         < /CipherData >
     < /EncryptedData >
 < /appSettings >

 

Decryption

Write Down Following Command

aspnet_regiis.exe -pd "appSettings
" -app  "/You Webapplication Name"



So After Apply Descryption your App Setting Looks Like :-

< appSettings>
     < add key="idbadge" value="Data Source=Comp-7;Initial Catalog=idbadge;Integrated Security=true;" / >
     < add key="path_photo" value="http://comp-7/WebCam_Last1/Webcam_Test_1_0_0_20.application?idbadge=" / >
     < add key="CrystalImageCleaner-AutoStart" value="true" / >
     < add key="CrystalImageCleaner-Sleep" value="60000" / >
     < add key="CrystalImageCleaner-Age" value="120000" / >
 < /appSettings >




 



Prev Post                                                      All Post                                                           Next Post



0 comments:

Post a Comment