title: Encrypting Username and Password safely c#
body: <p>I am trying to translate my PowerShell script into a C# WinForm. the form needs to carry out this process:</p>
  
  <ol>
  <li>Take a Username and Password you have provided, encrypt and save to a text file.</li>
  <li>a user logs onto a machine, runs another WinForm which can read the encrypted file and use the credentials.</li>
  </ol>
  
  <p>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?</p>
  
  <p>I am writing all of this (hopefully) in C# with Visual Studio 2015 Community.</p>
  
  <p>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 <a href="https://stackoverflow.com/questions/12657792/how-to-securely-save-username-password-local">How to securely save username/password (local)?</a> will not help me.</p>