Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Very similar to this SO question </p> <p><a href="https://stackoverflow.com/questions/1214582/ways-around-putting-a-password-in-code/1214689#1214689">Ways around putting a password in code</a></p> <p>Since, you did not mention the platform, I am assuming Windows. I am reproducing my answer to that question here.</p> <p>You have multiple options here.</p> <p>1.You can hash the password the very first time and store the hash to a file. Now the next time, you want to execute the code with elevated privileges, you need to accept/retype the password and re-compute the hash and match it with the stored hash. Only if it matches will you execute your code in elevation modes. You could hash using SHA. Please look at System.Crytography namespace for examples on hashing.</p> <p>2.Second option is to encrypt the password using algorithms like AES. However you will need to have a key to do this and you will have to worry about securing this key.</p> <p>3.Third option is to use DPAPI and encrypt the password but not worry about securing the keys - much easier option than 2.</p> <p>I would recommend 1 if you do not mind re-entering the password every time the application starts. If that is not a possibility, I would suggest going with 3 and use DPAPI.</p> <p>Here are some links to get you started.</p> <p>1.<a href="http://www.obviex.com/samples/dpapi.aspx" rel="nofollow noreferrer">http://www.obviex.com/samples/dpapi.aspx</a> 2. <a href="http://www.obviex.com/samples/Encryption.aspx" rel="nofollow noreferrer">http://www.obviex.com/samples/Encryption.aspx</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload