2
Answers

Encrypting a local user credentials file

Photo of John

John

15y
6k
1
I am writing a configuration tool that accesses different databases and it has two different views. One for the admins that have rights to see and edit the connection strings, and one for the employees that don't. The login data is stored in a local xml file and the whole file needs to be encrypted. The problem I am having is that I don't know how to safely hide the key inside the application. How do I make it so that the application can access the file to check user credentials without exposing the key inside of the executable?

Answers (2)

0
Photo of John
NA 5 0 15y
Turns out I wasn't thinking when I wrote the question. I ended up encrypting the individual strings in the file based on the the user's password. So now I have an unencrypted file that contains encrypted sections of text. Anyway thanks for the input. This thread can be closed.
0
Photo of David
NA 8 0 15y
Hey, not sure if this would help but you can encrypt the information, here is how

Make sure you include
using System.Security.Cryptography;

How to encrypt
Make two text boxes and rename them, 'txtEncryptInput' and 'txtEncryptOutput'
Make a button and add this:
string input = txtEncryptInput.Text;
string output = Convert.ToBase64String(Encoding.Unicode.GetBytes(input));
txtEncryptOutput.Text = output;


How to decrypt
Make two text boxes and rename them, 'txtDecryptInput' and 'txtDecryptOutput'
Make a button and add this:
string input = txtDecryptInput.Text;
string output = Encoding.Unicode.GetString(Convert.FromBase64String(input));
txtDecryptOutput.Text = output;


If you have any questions please ask ;)