Firstly, this is an educational question - not what I implement in a production application, as I am learning the basics of C #.
Currently, I have a solution containing 2 projects (actually 3, but one is unit testing);
Inside the class library, I have a class called Database.cs and it is communicating with the MySQL database. I do not directly communicate with this Database.cs class, but other classes inside the class library (e.g. Products.cs ). Although I need credentials to connect to this MySQL database, and I'm not sure where to go to make it safe.
Storing it in a class library / hardcoding credentials inside a class.
This does not make sense to me, since the user can easily capture the DLL, and he technically got the credentials in the database.
Pass the credentials through the form to the class (for example, Products.cs ) and this class passes it when initializing the database object
It can work, try and work, but I'm not sure if this is the βbestβ way to do it.
Write a static class containing credential properties
Again, if I create this static class inside the Class Library, then I almost do not belong to my first example. If I created this static class inside Form , I need to add a link to the Form project from my class library (not the way I want it).
I tried looking for things, but I apparently am not doing it right. Is there any other way to do this?