Decrypt parameter with C# API

Hello experts!

I use a configuration parameter, which I marked as "Encrypted" in Designer. In Web Designer component I need to get this parameter as clear value. There are posts on the forum where people decrypt parameters with VB, but i need to decrypt (and possibly encrypt) with C# inside Code Snippet in Web Designer.

How can I do this?


  • If you take a look at the samples, you will see that they always talk about the fact that you can only decrypt the value if the script or code is run by the Job Service so you cannot directly decode the configuration parameter in your custom C# code in WebDesigner.

  • One potential workaround is not to use config parms. Instead, decrypt web.config, add you parameter in the connectionStrings section (t<add name="myParm" connectionString="This script is encrypted using aspnet_regiis" />, then encrypt web.config it again. Using a backend script (which can be invoked from the front end), you can now use the variable from the front end

    look at aspnet_regiis.exe to see how you can encrypt/decrypt web.config. E.g. 

    aspnet_regiis.exe -pe "connectionStrings" -app <appName>

    The downside of this ofcourse is that you cannot use config parms to change the value, so each time there is a change the web.config needs to be decrypted, changed and encrypted again.