title: How to encrypt a connection string for a wpf application
body: <p>I have a distributed wpf application that I am trying to find a good way to encrypt the connection string in the app.config. I have tried renaming the app.config to web.config and running the aspnetiis_reg from the command line, that encrypts it but I later found out that only works for the user running the command, I have gotten code online that reads the connection string and encrypts the password and saves the app.config, and when running the application I can run a function that decrypts the password and saves it but that leaves a gaping whole that someone can locate the app.config and see the password when running the application, also you would have to know when the application is closed to go back to encrypt it. Can someone tell me the standard way to encrypt the password and decrypt at runtime with out having to write extra code on a WPF application. To note, I have migrated this application to enterprise library 5.0, the prev version was 1.0 and there was a way of putting the connectionstring in a separate file and encrypting and letting ent library or .net decrypt and not have to worry about it from their. what I was hoping for was a similiar way of just encrypting during build if possible an have .net decrypt without writing extra code for different cases</p>