'Java + MySQL: Do i have a good way to encrypt a password?

I want to hear your opinion on my following thought of encrypting passwords for my usage.

I have a JFrame program which uses a textfield (username) and a passwordfield to "login". I want the password to be encrypted and then tested on the password that is saved in my database (Tables: Username, password <- Password is encrypted)

My idea is to create a MD5 hash value (like here explained) of the password that is saved in the database. When logging in the software the password should be encrypted (via MD5 like here) and tested against the one in the db.

Is there a more efficient way, or does mine even work?

Thanks in advance <3



Solution 1:[1]

You should be using Bcrypt for password encryption instead.

Check:

https://github.com/patrickfav/bcrypt

Solution 2:[2]

Why not use MySQL itself?

SELECT PASSWORD(plaintext) FROM dual;

INSERT INTO users (username,password) VALUES(username, PASSWORD(plaintext));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MoralJustice
Solution 2 Clarius