AlaaL
AlaaL

Reputation: 343

Where and how to save SQL Server authentication in C#?

I am developing c# windows forms application which connects to sql server 2008. And i am allowing the user to configure connection to sql server when running app for the first time using a form i created, the from allow the user to chose between windows or sql authentication.

In windows authentication i save the connection string in appConfig, but when using sql authentication i cannot save the username and password of sql server there because it will be exposed to everyone using the computer because it's XML file, and i don't want to encrypt the password with a key because i heard it's easy to decrypt and i can't use hash because i will not be able to connect to the server with hashed password.

I searched a lot online and i didn't find anything related so what should i do ?

Thanks

Upvotes: 0

Views: 231

Answers (1)

JeremiahDotNet
JeremiahDotNet

Reputation: 910

Encrypt the password before storing it in app.config.

You can find info on how to encrypt a string in the answer(s) to this stackoverflow question: Encrypt/Decrypt String in .net

Upvotes: 1

Related Questions