-1

I am using org.apache.commons.codec.digest.DigestUtils.md5Hex() from Apache-Commons-Codec to calculate the mD5 of a concatenated string , however I get different mD5 hashcode values for the same string.

I see the following output , my expectation is that it will be same for a given string , but looks like its not .Whats the issue here ?

I generate the MD5 Hashcode using the following code and I am on centos platform.

    if (StringUtils.isNotBlank(concatenatedString)) {

        concatenatedString = StringUtils.deleteWhitespace(concatenatedString);
        //System.out.println("The concatenated string is "+concatenatedString);

        md5Hash = DigestUtils.md5Hex(concatenatedString);
        //System.out.println("The mD5 hashcode is  "+md5Hash);

    }

OutPut:

The concatenated string is JaclynSmith Women'sComfortDressPumpTori-Blackhttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+SmithProductDescriptionWhetheryourlookisdressyorcasual,addaclassictouchwiththesewomen'sToripumpsbyJaclynSmith.Theseshoesfeatureshinypatent-lookuppersandwrapped,medium-heightheels.Comfortablecushionedinsolesprovideextrasupportwhiletexturedrubberoutsolesaddanon-slipfit,makingtheseround-toepumpsperfectforeverydayofficewearoraformalnightout.Slip-ondesignSyntheticleatherupperRoundtoeCushionedinsoleTexturedrubberoutsole3-in.wrappedheelCare:WipecleanImportedif(isI18NConvReq()){$("#desca").hide();}24.99http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1001427212?hei=315&wid=315&op_sharpen=1&resMode=sharp&op_usm=0.9nullKmarthttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+Smithnullnull
The mD5 hashcode is  f20bd1bbd0063672e89d688268df0556

The concatenated string is JaclynSmith Women'sComfortDressPumpTori-Blackhttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+SmithProductDescriptionWhetheryourlookisdressyorcasual,addaclassictouchwiththesewomen'sToripumpsbyJaclynSmith.Theseshoesfeatureshinypatent-lookuppersandwrapped,medium-heightheels.Comfortablecushionedinsolesprovideextrasupportwhiletexturedrubberoutsolesaddanon-slipfit,makingtheseround-toepumpsperfectforeverydayofficewearoraformalnightout.Slip-ondesignSyntheticleatherupperRoundtoeCushionedinsoleTexturedrubberoutsole3-in.wrappedheelCare:WipecleanImportedif(isI18NConvReq()){$("#desca").hide();}24.99http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1001427412?hei=315&wid=315&op_sharpen=1&resMode=sharp&op_usm=0.9nullKmarthttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+Smithnullnull
The mD5 hashcode is  a0f99dca82fa3b3be846a9896614df9b

The concatenated string is JaclynSmith Women'sComfortDressPumpTori-Blackhttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+SmithProductDescriptionWhetheryourlookisdressyorcasual,addaclassictouchwiththesewomen'sToripumpsbyJaclynSmith.Theseshoesfeatureshinypatent-lookuppersandwrapped,medium-heightheels.Comfortablecushionedinsolesprovideextrasupportwhiletexturedrubberoutsolesaddanon-slipfit,makingtheseround-toepumpsperfectforeverydayofficewearoraformalnightout.Slip-ondesignSyntheticleatherupperRoundtoeCushionedinsoleTexturedrubberoutsole3-in.wrappedheelCare:WipecleanImportedif(isI18NConvReq()){$("#desca").hide();}24.99http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1001427112?hei=315&wid=315&op_sharpen=1&resMode=sharp&op_usm=0.9nullKmarthttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+Smithnullnull
The mD5 hashcode is  b298e7b5af0af3004a078a5c88ab9b09

The concatenated string is JaclynSmith Women'sComfortDressPumpTori-Blackhttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+SmithProductDescriptionWhetheryourlookisdressyorcasual,addaclassictouchwiththesewomen'sToripumpsbyJaclynSmith.Theseshoesfeatureshinypatent-lookuppersandwrapped,medium-heightheels.Comfortablecushionedinsolesprovideextrasupportwhiletexturedrubberoutsolesaddanon-slipfit,makingtheseround-toepumpsperfectforeverydayofficewearoraformalnightout.Slip-ondesignSyntheticleatherupperRoundtoeCushionedinsoleTexturedrubberoutsole3-in.wrappedheelCare:WipecleanImportedif(isI18NConvReq()){$("#desca").hide();}24.99http://c.shld.net/rpx/i/s/i/spin/image/spin_prod_1001427312?hei=315&wid=315&op_sharpen=1&resMode=sharp&op_usm=0.9nullKmarthttp://www.kmart.com/jaclyn-smith-women-s-comfort-dress-pump-tori-black/p-035VA51352201P//clothing-shoes-jewelry/b-1325032682?sbf=Brand&sbv=Jaclyn+Smithnullnull
The mD5 hashcode is  ffbaf47555d495b818426cc514e24c77
user1965449
  • 2,849
  • 6
  • 34
  • 51
  • Yes, MD5-hashing the same string should always produce the same value. Could you edit your question to include the code where you construct the string to be hashed and call the hashing functions? – Kenster Mar 01 '15 at 19:57

1 Answers1

7

Your inputs aren't the same. The antepenultimate* (or hundreds) digit of the number after spin_prod_ is 2 4 1 3 respectively. (* One of my favorite little-used words.)

dave_thompson_085
  • 34,712
  • 6
  • 50
  • 70