down0041
asked on
SqlConnection - How avoid hard coding password in config file.
I have a windows app, that I have created in VB.net. This is being deployed to a client's site, so in the properties of the SqlConnection, I am using "map property to a key in the configuration file".
However, I really dislike that the password (unencrypted) is hard coded in the configuration file.
Is there an alternative to hard coding the password?
I really like the flexibility of defining the database in the config file, but I know my client will not accept seeing their password hard coded.
Any help greatly appreciated.
Regards,
td
HERE IS SAMPLE CONFIG FILE:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="SqlConnection1.Connec tionString " value="workstation id=TOM;packet size=4096;user id=sa;data source=myPC;persist security info=True;initial catalog=myDataBase;passwor d=PWD123" />
</appSettings>
</configuration>
However, I really dislike that the password (unencrypted) is hard coded in the configuration file.
Is there an alternative to hard coding the password?
I really like the flexibility of defining the database in the config file, but I know my client will not accept seeing their password hard coded.
Any help greatly appreciated.
Regards,
td
HERE IS SAMPLE CONFIG FILE:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="SqlConnection1.Connec
</appSettings>
</configuration>
You could store the password as encrypted text, which only your app knows how to decrypt.
ASKER
Rob, thank you for your reply.
Sounds like a great solution. Can you please give me a little more detail. (ie. how exactly would you do this). I'm not a complete newbie, but I need some more direction, or an example.
Any help greatly appreciated.
Regards,
td
Sounds like a great solution. Can you please give me a little more detail. (ie. how exactly would you do this). I'm not a complete newbie, but I need some more direction, or an example.
Any help greatly appreciated.
Regards,
td
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Rob - Thank you!
td
td