同一字符串的不同MD5哈希(CryptoJS.MD5)

问题描述 投票:0回答:1

Edit:经过一些测试,我意识到差异是由“换行符”引起的。那么问题是,为什么在那些工具中换行符会有所不同?

Post:

使用CryptoJS我正在计算此博文底部的字符串MD5,并将其发送到Amazon Web服务,但是我计算的MD5值由亚马逊计算不同。

因此,我进行了一些在线测试,并意识到MD5的计算在某些md5计算网站中也有所不同。例如,md5hashgenerator与我计算相同的值,而onlinemd5计算与亚马逊相同的值。

我需要使用CryptoJS获得相同的Amazon MD5值

-CryptoJS.MD5: ec20007986ee9e1a5152c35d07e87fcc

-Amazon Scratchpad MD5: ee288aa4858481d7b1d7422c6fc4b3af

-md5hashgenerator.com: ec20007986ee9e1a5152c35d07e87fcc

-onlinemd5.com: ee288aa4858481d7b1d7422c6fc4b3af


用于计算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>
amazon-web-services md5 cryptojs
1个回答
0
投票

一个猜测是,它必须与其他提供者salting进行哈希处理之前的有效负载(在这种情况下为字符串化的XML)有关。我看不到太多文档,因为它们都是小型免费在线工具。最好明确一点,因为它可能导致类似这样的情况:即使有效载荷相同,您也无法确认使用不同盐值计算出的哈希值。

CryptoJS doesn't seem to have implemented salt addition作为显式功能。

© www.soinside.com 2019 - 2024. All rights reserved.