MD5 on "insert screen" vs. SQL command screen

View: New views
3 Messages — Rating Filter:   Alert me  

MD5 on "insert screen" vs. SQL command screen

by Chris Mega :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi -

I am using phpmyadmin through my web host provider.

I have a table with 2 fields - "email" (varchar 128) and "md5email" (char32)

The "email" field is populated via a text file upload using phpmyadmin - no problem.
All email addresses are standard form, address@...

But now I need to set the "md5email" field to the MD5() of each email address.

If I use the phpmyadmin "SQL" command tab and enter the query manually:
  UPDATE `table` SET `md5email`=MD5(`email`) WHERE 1
it "works", meaning it populates the md5email field with 32-character values.

BUT here's the problem.
When I browse, and click on a record and manually edit it (using the pencil icon, which brings up the entry form for that record),
and use the MD5 function in the pulldown menu, and copy the email address from the "email" field to populate the md5email field,
it gives a completely different 32-character value.

I think it has something to do with the "@" sign in the email field.  When I remove the "@" from an email address, and run
the manual SQL query, or the Edit Form, they both produce the same MD5 calculation.

WHAT IS THE DIFFERENCE BETWEEN USING MD5() IN A SQL COMMAND, AND USING THE EDIT-FORM "MD5" PULLDOWN
FUNCTION?

Totally stumped by this.

Thank you
- Chris


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Phpmyadmin-users mailing list
Phpmyadmin-users@...
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-users

Re: MD5 on "insert screen" vs. SQL command screen

by Michal Čihař :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

Dne Tue, 18 Aug 2009 08:34:48 -0700 (PDT)
Chris Mega <chrismega@...> napsal(a):

> When I browse, and click on a record and manually edit it (using the pencil icon, which brings up the entry form for that record),
> and use the MD5 function in the pulldown menu, and copy the email address from the "email" field to populate the md5email field,
> it gives a completely different 32-character value.
>
> I think it has something to do with the "@" sign in the email field.  When I remove the "@" from an email address, and run
> the manual SQL query, or the Edit Form, they both produce the same MD5 calculation.
>
> WHAT IS THE DIFFERENCE BETWEEN USING MD5() IN A SQL COMMAND, AND USING THE EDIT-FORM "MD5" PULLDOWN
> FUNCTION?

Can you show us different values for some address? At least we can say
which one is wrong and focus on that problem.

--
        Michal Čihař | http://cihar.com | http://blog.cihar.com


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Phpmyadmin-users mailing list
Phpmyadmin-users@...
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-users

signature.asc (204 bytes) Download Attachment

Re: MD5 on "insert screen" vs. SQL command screen

by Chris Mega :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Michal -
I may have narrowed it down, but I need further testing, or a way to programmatically correct this:

The problem is during the IMPORT of my email file.  Using phpmyadmin, if I set the LINE TERMINATOR to '\n', rather than '\r\n',
my MD5's "fail".  But I think that's because my lines really are terminated by \r\n, and when I said they're terminated with \n,
the "\r" character is stored in the email field!  Thus when md5 is calculated, it's including the trailing \r.

I can never "see this" using phpmyadmin because the edit/browse/query functions will never DISPLAY the \r character on a web page
for me to see.

But when I do it "by hand" using the INSERT FORM, the \r can't be typed in to a form field, therefore MD5 creates a different value.

So my question may be how to absolutely know the terminator characters on my input file, or run a script after the import to
clean up trailing control characters.

- Chris


From: Michal Čihař <michal@...>
To: phpmyadmin-users@...
Sent: Tuesday, August 18, 2009 11:45:53 AM
Subject: Re: [Phpmyadmin-users] MD5 on "insert screen" vs. SQL command screen

Hi

Dne Tue, 18 Aug 2009 08:34:48 -0700 (PDT)
Chris Mega <chrismega@...> napsal(a):

> When I browse, and click on a record and manually edit it (using the pencil icon, which brings up the entry form for that record),
> and use the MD5 function in the pulldown menu, and copy the email address from the "email" field to populate the md5email field,
> it gives a completely different 32-character value.
>
> I think it has something to do with the "@" sign in the email field.  When I remove the "@" from an email address, and run
> the manual SQL query, or the Edit Form, they both produce the same MD5 calculation.
>
> WHAT IS THE DIFFERENCE BETWEEN USING MD5() IN A SQL COMMAND, AND USING THE EDIT-FORM "MD5" PULLDOWN
> FUNCTION?

Can you show us different values for some address? At least we can say
which one is wrong and focus on that problem.

--
    Michal Čihař | http://cihar.com | http://blog.cihar.com


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Phpmyadmin-users mailing list
Phpmyadmin-users@...
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-users