I am trying to translate my PowerShell script into a C# WinForm. the form needs to carry out this process:
- Take a Username and Password you have provided, encrypt and save to a text file.
- a user logs onto a machine, runs another WinForm which can read the encrypted file and use the credentials.
Now, I was wondering, I could encrypt with AES using an AES key hard-coded into both WinForms. How can I ensure I keep the hardcoded key safe? Can I encrypt the compiled WinForm? What options do I have if this is not ideal?
I am writing all of this (hopefully) in C# with Visual Studio 2015 Community.
EDIT: DPAPI is not a viable solution, as the credentials will be used not only just in a separate solution, but also on a different machine, so the thread How to securely save username/password (local)? will not help me.