10 Apr

Encrypt Connection String in web.config

In this post we will learn how to encrypt connection string in web.config

Implementation

        1. RunDeveloper Command Prompt for VS2013 as Administrator
        2. Change directory to Microsoft .Net Framework Folder
        3. Choose .Net framework folder v4.0.30319
        4. Create a website in the IIS
        5. Register your web application using aspnet_regiis command
Developer Command Prompt for VS2013

Developer Command Prompt for VS2013

Encrypt Web Config

 

Encrypt Web Config

Encrypt Web Config

3-1

 

 

 

3

 

Now look at Encrypted web config file

web config encrypt

web config encrypt

Encrypt  Connection String in web.config Commands

C:\Windows\system32>cd..

C:\Windows>cd Microsoft.NET

C:\Windows\Microsoft.NET>cd Framework

C:\Windows\Microsoft.NET\Framework>cd v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -site "EncryptDemo" -app "/" -pe "connectionStrings"

aspnet_regiis.exe -site "NameoftheSite" -app "/" -pe "EncryptingTag"

Decrypt  Connection String in web.config Commands

From the above command change -pe to -pd to decrypt

aspnet_regiis.exe -site "EncryptDemo" -app "/" -pd "connectionStrings"
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -site "EncryptDemo" -app "/" -pd "connectionStrings"

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>