Topics: General discussion
Jun 4, 2013 at 12:51 PM
Currently the Enterprise library following encryption

• RSAProtectedConfigurationProvider
• DataProtectedConfigurationProvider

Can we have our own method of encryption within Enterprise library. If Yes? How it can be done.
Jun 4, 2013 at 9:28 PM
Enterpise Library uses the protected configuration providers included in the .NET Framework (i.e. RSAProtectedConfigurationProvider and DataProtectedConfigurationProvider). You can read about them in Specifying a Protected Configuration Provider.

You can create a custom protected configuration provider; you can read about that in Implementing a Protected Configuration Provider. If you follow the example and install to the GAC and configure machine.config then the custom provider will appear in the configuration tool.

Of course, the custom provider will be required to be deployed along side the application so that the configuration can be decrypted.

Randy Levy
Enterprise Library support engineer
Support How-to
Jun 5, 2013 at 10:23 AM
Thanks for the reply!!!!

I have done as per the example , when I try to encrypt get the following error

The protection provider 'TripleDESProvider' was not found.

Also I do not see the TripleDESProvider under the Enterprise library configuration tool.I have added the details to Machine.config
Jun 5, 2013 at 11:10 AM
Sorry now I am able to encrypt.But not able to Decrypt the same in my application The protection provider 'TripleDESProvider' was not found.
Jun 5, 2013 at 5:33 PM
Probably you only modified machine.config for either 32 bit (C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config) or 64 bit (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config) and the test app is running as the other type.

I'm going to guess that you configured the 64 bit machine.config but your app is running as 32 bit ("Prefer 32-bit" build setting).

If you setup both machine.configs then it should decrypt properly. Or, another approach to ensure that the provider is configured for the application is to provide the setting in the app.config:
  <configProtectedData defaultProvider="RsaProtectedConfigurationProvider">
      <add name="TripleDESProtectedConfigurationProvider" type="MyCustomConfigProvider.TripleDESProtectedConfigurationProvider, MyCustomConfigProvider, Version=, Culture=neutral, PublicKeyToken=12333b56bdeab820" description="Uses CryptProtectData and CryptUnProtectData Triple DES to encrypt and decrypt" KeyFilePath="C:\keys\keys.txt"/>

If you are using the standalone configuration tool you could also add the above to standalone configuration tool config file (i.e. EntLibConfig.exe.config).

Randy Levy
Enterprise Library support engineer
Support How-to