user2070610
user2070610

Reputation: 35

PHP MD5 different results

I'm try to get a MD5 value of a string

test%40abc.com05a671c66aefea124cc08b76ea6d30bb11.250.55.65MAIDAz3yq007svng4pbhwvtg32mgif3llea7i

From different MD5 online convert sites I got different results

In http://www.md5.cz/, it returns: c4c794a5488a729a715a877111251405

In http://www.adamek.biz/md5-generator.php, it returns: 658451b9193e198190873d0d4f20df21

Do anyone have ideas why they got different results?

Upvotes: 1

Views: 2627

Answers (3)

Aipo
Aipo

Reputation: 1985

I found this: @ and %40 has the same value, becouse @ is converted to %40. Maybe RCF 1738 and RCF3986 diferences cause this problem?

urlencode function and rawurlencode are mostly based on RFC 1738.

However, since 2005 the current RFC in use for URIs standard is RFC 3986.

Here is a function to encode URLs according to RFC 3986.

<?php
function myUrlEncode($string) {
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25',

'%23', '%5B', '%5D'); $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]"); return str_replace($entities, $replacements, urlencode($string)); } ?>

Upvotes: 0

Ryan Vincent
Ryan Vincent

Reputation: 4513

The '%' in the string is confusing at least one of the sites. When you remove the '%' sign then both sites give the same MD5 hash. There are no 'salts' added by the websites.

I suspect that one of the sites may be using the 'urldecode' function on the input string. the results are:

string 'Input    : test%40abc.com05a671c66aefea124cc08b76ea6d30bb11.250.55.65MAIDAz3yq007svng4pbhwvtg32mgif3llea7i' (length=102)
string 'urldecode: test@abc.com05a671c66aefea124cc08b76ea6d30bb11.250.55.65MAIDAz3yq007svng4pbhwvtg32mgif3llea7i' (length=104)

The website www.md5.cz returns the same result of: c4c794a5488a729a715a877111251405

for both of the above input strings,

Upvotes: 1

les
les

Reputation: 584

One or both may be using random salts, which are intended to add a unique touch to the outputs of identical inputs.

Upvotes: 0

Related Questions