<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to replicate sha256 hash example from CyberSource REST API documentation? in cybersource APIs</title>
    <link>https://community.developer.cybersource.com/t5/cybersource-APIs/How-to-replicate-sha256-hash-example-from-CyberSource-REST-API/m-p/84623#M503</link>
    <description>&lt;P&gt;I am investigating the CyberSource REST API and want to test the JSON Web Token Authentication method as documented here:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/authentication/GenerateHeader/jwtTokenAuthentication.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/authentication/GenerateHeader/jwtTokenAuthentication.html&amp;nbsp;&lt;/A&gt;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;/echat&lt;/A&gt;&lt;A href="https://chatrandom.download/omegle/" target="_blank" rel="noopener"&gt;random&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am unable to replicate the sha256 hash of the JSON payload described in the JWT Payload/Claim Set section.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "clientReferenceInformation" : {
    "code" : "TC50171_3"
  },
  "orderInformation" : {
    "amountDetails" : {
      "totalAmount" : "102.21",
      "currency" : "USD"
    }
  }
}&lt;/PRE&gt;&lt;P&gt;I've attempted to use the sha256sum command in binary and text format on a file containing the payload example. I've also attempted running this command on different permutations of this payload, such as without whitespace or newlines.&lt;/P&gt;&lt;P&gt;I expect to get the example hash of&lt;/P&gt;&lt;P&gt;2b4fee10da8c5e1feaad32b014021e079fe4afcf06af223004af944011a7cb65c&lt;/P&gt;&lt;P&gt;but instead get&lt;/P&gt;&lt;P&gt;f710ef58876f83e36b80a83c8ec7da75c8c1640d77d598c470a3dd85ae1458d3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and other dissimilar hashes.&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Hash functions have a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Avalanche_effect" target="_blank" rel="nofollow noopener noreferrer"&gt;avalanche effect&lt;/A&gt;, wherein any different bit in the input changes a lot the output hash. If the site's original example used a different encoding, or had a different order for the JSON elements, or even had more or less tabs, spaces, line breaks, or any other "trash" character, you'll have a hard time to find a fitting message for the hash showed in the site.&lt;/P&gt;&lt;P&gt;Usually, cryptographic solutions use canonicalizations to avoid this kind of problem (different hash values for semantically equal messages). However, the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.rfc-editor.org/rfc/rfc7519" target="_blank" rel="nofollow noopener noreferrer"&gt;JWT specification&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;doesn't specify any type of canonicalization for JSON.&lt;/P&gt;&lt;P&gt;In short, I think you don't have to worry about this. Your JWT implementation will be correct as long you use a valid (correctly implemented) hash function.&lt;/P&gt;&lt;P&gt;Also, I noticed that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.rfc-editor.org/rfc/rfc7519" target="_blank" rel="nofollow noopener noreferrer"&gt;JWT specification&lt;/A&gt;&amp;nbsp;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;/echat&lt;/A&gt;&lt;A href="https://chatspin.download" target="_blank" rel="noopener"&gt;spin&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;doesn't specify a "Digest" field for the JWT payload. So, you may not even need to use this field. Unless CyberSource REST API makes it mandatory.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 10:58:46 GMT</pubDate>
    <dc:creator>SomyNopatri</dc:creator>
    <dc:date>2022-10-19T10:58:46Z</dc:date>
    <item>
      <title>How to replicate sha256 hash example from CyberSource REST API documentation?</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/How-to-replicate-sha256-hash-example-from-CyberSource-REST-API/m-p/84623#M503</link>
      <description>&lt;P&gt;I am investigating the CyberSource REST API and want to test the JSON Web Token Authentication method as documented here:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/authentication/GenerateHeader/jwtTokenAuthentication.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/authentication/GenerateHeader/jwtTokenAuthentication.html&amp;nbsp;&lt;/A&gt;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;/echat&lt;/A&gt;&lt;A href="https://chatrandom.download/omegle/" target="_blank" rel="noopener"&gt;random&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am unable to replicate the sha256 hash of the JSON payload described in the JWT Payload/Claim Set section.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "clientReferenceInformation" : {
    "code" : "TC50171_3"
  },
  "orderInformation" : {
    "amountDetails" : {
      "totalAmount" : "102.21",
      "currency" : "USD"
    }
  }
}&lt;/PRE&gt;&lt;P&gt;I've attempted to use the sha256sum command in binary and text format on a file containing the payload example. I've also attempted running this command on different permutations of this payload, such as without whitespace or newlines.&lt;/P&gt;&lt;P&gt;I expect to get the example hash of&lt;/P&gt;&lt;P&gt;2b4fee10da8c5e1feaad32b014021e079fe4afcf06af223004af944011a7cb65c&lt;/P&gt;&lt;P&gt;but instead get&lt;/P&gt;&lt;P&gt;f710ef58876f83e36b80a83c8ec7da75c8c1640d77d598c470a3dd85ae1458d3&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and other dissimilar hashes.&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Hash functions have a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Avalanche_effect" target="_blank" rel="nofollow noopener noreferrer"&gt;avalanche effect&lt;/A&gt;, wherein any different bit in the input changes a lot the output hash. If the site's original example used a different encoding, or had a different order for the JSON elements, or even had more or less tabs, spaces, line breaks, or any other "trash" character, you'll have a hard time to find a fitting message for the hash showed in the site.&lt;/P&gt;&lt;P&gt;Usually, cryptographic solutions use canonicalizations to avoid this kind of problem (different hash values for semantically equal messages). However, the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.rfc-editor.org/rfc/rfc7519" target="_blank" rel="nofollow noopener noreferrer"&gt;JWT specification&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;doesn't specify any type of canonicalization for JSON.&lt;/P&gt;&lt;P&gt;In short, I think you don't have to worry about this. Your JWT implementation will be correct as long you use a valid (correctly implemented) hash function.&lt;/P&gt;&lt;P&gt;Also, I noticed that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.rfc-editor.org/rfc/rfc7519" target="_blank" rel="nofollow noopener noreferrer"&gt;JWT specification&lt;/A&gt;&amp;nbsp;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;/echat&lt;/A&gt;&lt;A href="https://chatspin.download" target="_blank" rel="noopener"&gt;spin&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;doesn't specify a "Digest" field for the JWT payload. So, you may not even need to use this field. Unless CyberSource REST API makes it mandatory.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 10:58:46 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/How-to-replicate-sha256-hash-example-from-CyberSource-REST-API/m-p/84623#M503</guid>
      <dc:creator>SomyNopatri</dc:creator>
      <dc:date>2022-10-19T10:58:46Z</dc:date>
    </item>
  </channel>
</rss>

