Reputation: 532
On my program, I prompt the user for a username and password, and I use passwordField
to keep people looking at the screen from seeing it. Now when I use the password to connect to the database what should I use?
java.sql.Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/database", username.getText(), passwordField.getText());
1) .getText()
works but its deprecated
2) .getPassword().toString()
which maybe the same as .getText()
but just longer Otherway?
I do not think that any VITAL information maybe lost using my program, but still would like to do things the right way (or understand why). I thought MD5 was the best way to go incase people sniff the communication.
Upvotes: 0
Views: 260
Reputation: 5291
Two things,
When you are creating a website, or anything that requires password to go through the wire, that's when you should try hashing(with salt) it and storing it hashed in the database.
Upvotes: 1