Currently I'm working on software which connects to a MySQL database in order to retrieve and store data. The software itself is running as it should be, but I want to implement some new security features.
One of these security features is to store the password of the database user as a hash and not in plain text. For the record, I am NOT using a table to verify users, I'm talking about the database user to connect to the database itself.
I'm currently using a MySQL connection string which sends the password in plain text:
public abstract Database()
{
ReadConfig();
connectionstring = "SERVER=" + server + ";" +
"DATABASE=" + database + ";" +
"UID=" + username + ";" +
"PASSWORD=" + password + ";";
try
{
connection = new MySqlConnection(connectionstring);
}
catch (MySqlException ex)
{
LogService.Log("ERROR - " + ex.ToString());
}
}
I also store this data on the user's computer, so the user can change the server address, database, username and password. As I said, this is stored in plain text. Server addresses, database names and usernames stored as plain text are fine by me, but I don't want to store the password in plain text.
Generating a SHA1 hash (or other hashing method) is not the problem, as I already have a method to generate these hashes.
In short, I would like to save the password as a hash, and use that hash in de connection string. How can I implement this?
EDIT: I'm aware this is a 'security through obscurity' solution and it isn't the best way to extend the security of my software. I'm looking into ways to find out how to use challenge-response methods, but in the mean time I would like to implement the above.