Encrypting Configuration Section

Topics: Cryptography Application Block
Apr 19, 2007 at 8:21 PM
Edited Apr 19, 2007 at 8:34 PM
Hi there.

I noticed that when you encrypt the configuration section of an app.config file, the resulting encrypted data is all ASCII (meaning no funky characters that makes the app.config very unhappy). Can you tell me how you accomplish this? When I use the EntLib methods in my code, I get the funky characters!

Thanks, Mike
Apr 19, 2007 at 9:37 PM
The configuration encryption functionality is actually a part of .NET, rather than EntLib, so the implementation of the Cryptoraphy Application Block is not the same. But the general approach to converting binary data to ASCII is to use Base64 encoding. I believe this is what the .NET configuration encryption does, and there are also overloads in the Crypto block that will convert the encrypted data to base64.