Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide string in open-source code? [duplicate]

I've been working on a Java project for a while now, and before I make it available for public download, I'd like to add in a feature which requires me to connect to a MySQL database. My question is simple: How would I go about hiding the password to the database if the code is open-source?

like image 624
Max Roncace Avatar asked Jan 19 '13 06:01

Max Roncace


3 Answers

Store the database connection settings separate from your code.

like image 55
ta.speot.is Avatar answered Sep 22 '22 20:09

ta.speot.is


You can put the password in some sort of configuration file like an ini file. During the setup/installation stage, get the password from the user and populate it in the configuration file either by code, or allow them to do it manually.

like image 31
saji89 Avatar answered Sep 24 '22 20:09

saji89


As far as I know, there is no correct answer. You can try really hard to obfuscate or hide it, but if the password or a method of calculating it is in your JAR, a persistent and skilled user will find it.

There is a much better answer than I could give here: How can I protect MySQL username and password from decompiling?

like image 20
Cory Kendall Avatar answered Sep 21 '22 20:09

Cory Kendall