Using CryptoJS I am calculating MD5 of the string at the bottom of this post, and send it to Amazon web services, however the MD5 value that I calculate, and the amazon calculates differs.
So I did some online tests, and realized that MD5 calculation differs in some md5 calculating websites too. For example, md5hashgenerator calculates same value with me, and onlinemd5 calculates same value as amazon.
What I need is to get the same MD5 value of Amazon using CryptoJS
- CryptoJS.MD5: ec20007986ee9e1a5152c35d07e87fcc
- Amazon Scratchpad MD5: ee288aa4858481d7b1d7422c6fc4b3af
- md5hashgenerator.com: ec20007986ee9e1a5152c35d07e87fcc
- onlinemd5.com: ee288aa4858481d7b1d7422c6fc4b3af
String to calculate MD5:
<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>false</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
Edit: After some test, I realised that the difference is caused because of the "newline" character. So the question is why newline is treated differently in those tools and how can I achieve the same results with Amazon using CryptoJS?