Solved

What is the probability of two different strings having the same MD5 hash?

Posted on 2009-05-13
4
650 Views
Last Modified: 2012-05-06
Hi,

I am planning to create my own query cache. I will be looking up the query results from the cache using an MD5 hash of the query string. There will be tens of thousands of queries stored in the cache. What is the likelihood of two different query strings having the same MD5 hash?

The reason I ask is because to my knowledge MySQL's native query cache looks up cached results using the full query string, instead of using a hash of the query string (which would be faster and use less storage), and I wondered if this was due to potential hash conflicts.

Thanks
0
Comment
Question by:tomp_gl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Assisted Solution

by:racek
racek earned 50 total points
ID: 24373331
No problem, but before MD5 you need to
- replace all double spaces
- change all to capitals
- replace variables with ? or similar
- maybe replace ALIAS table and column names with whole table names :-) because different programmers use different aliases
- LEF JOIN to LEFT OUTER JOIN because different programmers use different aliases
etc

0
 
LVL 84

Accepted Solution

by:
ozo earned 150 total points
ID: 24373336
with 10,000 querys, approximately 10,000^2 / 2^128
0
 
LVL 22

Assisted Solution

by:dportas
dportas earned 50 total points
ID: 24373796
The risk of accidental MD5 collisions is vanishingly small. You don't need to worry about it. There is a possible risk of deliberately constructed collisions, which may present a security risk in some unusual circumstances.

As racek suggests, for your scheme to be effective you'll probably have to use some canonical form of the query rather than its raw format.
0
 
LVL 14

Assisted Solution

by:racek
racek earned 50 total points
ID: 24374830
another thing is that query is stored in MySQL including comments like

SELECT *
FROM yourtable  /* changed 2009-01-05 */
Where ...;
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to generate a csr to request an intermediate ca on os x 3 64
when to use sequences in mysql 4 38
How to fix Datetime in MySQL? 4 64
MySQL - need to join three tables 2 54
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question