Scenario: I am trying to decrypt fields in a database using a standard console app. This is more of a disaster recovery scenario where I need a quick and dirty app to decode values when there isn't time to build up an entire App server. Traditionally the app server is a MVC app which interacts and encodes/decodes some of the DB fields using MachineKey.Protect and MachineKey.Unprotect.
The problem:
I have imported the system.web.security dll, however, the only machinekey it will read is the one stored in the HKCU\Software\Microsoft\ASP.NET\4.0.30319.0\AutoGenKeyV4
I have tried putting it under
<system.web>
<machineKey decryptionKey="xxx" validationKey="yyy"/>
</system.web>
in the app.config file, made a machine.config file and also a web.config file and it doesn't read any of these at startup, it will always show the key from the registry. I have the machine key from the production server, I just have to somehow force my console app to use it.
That is the problem I have and I need assistance with. How can I set the machinekey in a console app and have it read from the application configuration file. Better yet would be have it read from input from the user during runtime, but i'll totally settle for it in the configuration file.
Any help is appreciated.