Introduction
In this blog, we are discussing web.configuration file encryption and decryption using a batch file.
What is the use of encrypting the web.configuration file?
We all know configuration files will have confidential data like a database connection string. Under the app settings section we used to have confidential data. As per the security guidelines or applications, security says we need to encrypt the configuration file in the server. Let us see how we can encrypt and decrypt the configuration files using batch file instead of command prompt.
Step 1
Please create one text file and name it as encryption.bat. Please remember that file extension will be a .bat.
The below commands are useful for encrypting the app settings and connection strings in the configuration file.
- echo changing the directory
- cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
- echo started encrypting the connection strings
- ASPNET_REGIIS -pef "connectionStrings" "file path"
- echo success
- echo started encrypting the app settings
- aspnet_regiis.exe -pef appSettings "file path"
- echo success
- Pause
Note
File path should be pointing to your configuration file.
Step 2
The below commands are useful for decrypting the app settings and connection strings in the configuration file.
Please create one text file and name it as decrption.bat. Please remember that file extension will be a .bat.
- echo changing the directory
- cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
- echo started decrypting the app settings
- aspnet_regiis.exe -pdf appSettings "file path"
- echo success
- echo started decrypting connection strings
- aspnet_regiis.exe -pdf "connectionStrings" "file path"
- echo success
- Pause
Summary
In this blog, we discussed the configuration of file encryption and decryption using the batch file.