Simple Authentication

Hi All

I am very new to Java with MySQL and to SQL language in general. I am trying to create a very simple program that takes a user id and password and 'authenticates' the user using a table in an SQL DB.

I looking for some help as to how best to do this. Can I simply use:

CREATE TABLE users (

id CHAR(10) NOT NULL,

passwordcrypt CHAR(20) NOT NULL,

PRIMARY KEY (id)

);

but then how do i handle the encyption of the password?

Or can i simply do this hashing technique? But is there a Java class that will simply handle this? All I want to be able to do is , in the simplest possible way, securley authenticate a user using Java and MySQL....is this possible?

[727 byte] By [java_newbea] at [2007-11-27 9:30:26]
# 1
You may find this MD5 hasher snippet useful: http://balusc.xs4all.nl/srv/dev-jep-use.html#GenerateMD5Hash
BalusCa at 2007-7-12 22:41:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Thankyou for this...I can now hash the password and send it to the database, however

What do i set the database up for? Just Chars? and when i authenticate the user is it simply thecase that this MD5 program converts the password they enter to the hashed value and this value is compared against the one in the database?

java_newbea at 2007-7-12 22:41:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
That's correct. When an user registers, hash it's password before saving into DB. When an user logs in, check if the DB returns one row on the given username and the hashed password.
BalusCa at 2007-7-12 22:41:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...