Here are the commands to encrypt web.config file without any programming…
For encryption
aspnet_regiis -pef "Section" "Path exluding web.config"
For Decryption
aspnet_regiis -pdf "Section" "Path exluding web.config"
From this commands you can encrypt or decrypt all the section.