MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 8th, 2001, 12:15 PM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

Hi everbody.

I am a new user.
I have the following question.
As I know, mysql support MD5 encryption to store the password.

(1) How can I set the mysql use MD5 to store password?
(2) I am using mm.mysql as Java driver, how can I set the Java also use MD5 to check the passord?


Best Tks.
Alfred

Reply With Quote
  #2  
Old April 8th, 2001, 07:41 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Let's say you want to set "my_password" as your password. Your SQL statement would look like this:

INSERT INTO table (password) VALUES (MD5('my_password'))

Then, when you're checking the username and password of someone trying to log in, you'd do something like this (assuming you have the variables $username and $password)

SELECT * FROM table WHERE username = '$username' AND password = MD5('$password')

If that returns any rows, then you have a match.

---John Holmes...

Last edited by Sepodati : April 9th, 2001 at 04:17 AM.

Reply With Quote
  #3  
Old April 9th, 2001, 03:53 AM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
but when I try to execute that insert statement, it shows.

ERROR 1064: You have an error in your SQL syntax


Is there anything need to be setup first?

Reply With Quote
  #4  
Old April 9th, 2001, 04:18 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
I forgot to include one of the closing parenthesis...that could of been it. Or it could be your mysql version. what version are you using? or you could be messing up the query...what is the table structure and query you are using?

---John Holmes...

Reply With Quote
  #5  
Old April 9th, 2001, 10:49 AM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Mysql version is :
The MySql is installed through RPM

mysql Ver 9.38 Distrib 3.22.32, for pc-linux-gnu (i686)

This is classmate table under test database

+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| school_no | varchar(10) | YES | | NULL | |
| name | varchar(10) | YES | | NULL | |
| tel_no | varchar(10) | YES | | NULL | |
| address | varchar(40) | YES | | NULL | |
| birth | date | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+

When I try to use the following sql statement for testing MD5 function:

mysql> connect test;
mysql> insert into classmate(school_no) values (MD5('pass'));
ERROR 1064: You have an error in your SQL syntax near '('pass'))' at line 1

It shows above error message

Reply With Quote
  #6  
Old April 9th, 2001, 07:53 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
Looks like you need to upgrade if you want to use MD5().

---John Holmes...

Reply With Quote
  #7  
Old April 9th, 2001, 08:00 PM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Which version you are using?

Is it automatically uninstall previous version if I use RPM ?

Thank you

Reply With Quote
  #8  
Old April 9th, 2001, 08:10 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
I don't know anything about RPMs.

There is a stable release of 3.23 out, you should load that.

---John Holmes...

Reply With Quote
  #9  
Old April 9th, 2001, 08:17 PM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thaks advance.

I will try it later.

Reply With Quote
  #10  
Old April 9th, 2001, 08:47 PM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
After I have upgraded MySql. the insert statement is okay

Thank you very much

Reply With Quote
  #11  
Old April 9th, 2001, 08:55 PM
alfredau alfredau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 7 alfredau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
After I have inserted value

mysql> insert into classmate(school_no) values (MD5('123'));
Query OK, 1 row affected (0.00 sec)


When I want to select it:

mysql> select * from classmate where school_no = MD5('123');
Empty set (0.00 sec)


It returns empty set. Why? Is any wrong in my MySQL server or select statement?

Best Tks

Reply With Quote
  #12  
Old April 9th, 2001, 08:57 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
MD5() always creates a 32 character string and you're saving it in a 10 character field. So they won't match. Make your field a varchar(32)

---John Holmes...

Reply With Quote
  #13  
Old April 9th, 2001, 09:01 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 10 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
It even says it in the manual...
Quote:
MD5(string)
Calculates a MD5 checksum for the string. Value is returned as a 32 long hex number that may, for example, be used as a hash key:
mysql> select MD5("testing");
-> 'ae2b1fca515949e5d54fb22b8ed95575'

This is an "RSA Data Security, Inc. MD5 Message-Digest Algorithm".

Love those manuals...

---John Holmes...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > About MD5 in mysql and Java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT