<?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 Transaction Hash Upgrade Guide for API using VB.NET. Hashes don't match in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/66921#M40414</link>
    <description>&lt;P&gt;Help please. I can't get the Hash values to match.&amp;nbsp; I'm trying to follow the instructions from the API Upgrade guide here:&amp;nbsp; &lt;A href="https://developer.authorize.net/support/hash_upgrade/" target="_blank"&gt;https://developer.authorize.net/support/hash_upgrade/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 1 - I've generated my signature key and stored it in my web.config&lt;/P&gt;&lt;P&gt;Step 2 - &lt;SPAN&gt;Convert the Signature Key into a&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/byte" target="_blank" rel="noopener"&gt;byte array&lt;/A&gt;&lt;SPAN&gt;. I've skipped this step because&lt;/SPAN&gt;, "&lt;SPAN&gt;For C# users, Authorize.Net provides the following code for converting the Signature Key into a byte array and calculating the HMAC-SHA512 hash."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3 - create a message string from&amp;nbsp; the&amp;nbsp;&lt;SPAN&gt;API Login ID, the&amp;nbsp;&amp;nbsp;transaction ID and the amount.&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;I'm pulling my APILoginID from where I stored it in my web.config&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I'm pulling the transaction ID this way:&amp;nbsp;&amp;nbsp;Dim APITransID As String = response.transactionResponse.transId&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The guide says to use "The transaction amount that we send in&amp;nbsp;&lt;STRONG&gt;createTransactionResponse&amp;nbsp;&lt;/STRONG&gt;in the&amp;nbsp;&lt;STRONG&gt;amount&amp;nbsp;&lt;/STRONG&gt;element. " However, there is no amount element in response.transactionResponse, so&amp;nbsp;&lt;/SPAN&gt;I'm using the same amount variable I'm using to send in the transaction:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;Dim transactionRequest = New transactionRequestType With {&lt;BR /&gt;.transactionType = AuthOrAuthCapture,&lt;BR /&gt;.amount = amount,&lt;BR /&gt;.payment = paymentType,&lt;BR /&gt;.billTo = billingAddress,&lt;BR /&gt;.order = OrderInfo&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;So my message string looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Dim MessageString As String = String.Format("^{0}^{1}^{2}^", ApiLoginID, APITransID, amount)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 4 - "&lt;SPAN&gt;Use HMAC-SHA512 to hash the byte array form of the Signature Key from Step 2 with the message string from Step 3&lt;/SPAN&gt;" - But I'm combining step 2 &amp;amp; step 4 using the provided c# code (converted to vb):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;SignatureKey is being pulled from my web.config&lt;/LI&gt;&lt;LI&gt;I'm calling the funciton with this line:&lt;BR /&gt;Dim hashedSignatureAndMessage As String = HMACSHA512(SignatureKey, MessageString)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Function HMACSHA512(ByVal key As String, ByVal textToHash As String) As String&lt;BR /&gt;If String.IsNullOrEmpty(key) Then Throw New ArgumentNullException("HMACSHA512: key", "Parameter cannot be empty.")&lt;BR /&gt;If String.IsNullOrEmpty(textToHash) Then Throw New ArgumentNullException("HMACSHA512: textToHash", "Parameter cannot be empty.")&lt;/P&gt;&lt;P&gt;If key.Length Mod 2 &amp;lt;&amp;gt; 0 OrElse key.Trim().Length &amp;lt; 2 Then&lt;BR /&gt;Throw New ArgumentNullException("HMACSHA512: key", "Parameter cannot be odd or less than 2 characters.")&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Try&lt;BR /&gt;Dim k As Byte() = Enumerable.Range(0, key.Length).Where(Function(x) x Mod 2 = 0).[Select](Function(x) Convert.ToByte(key.Substring(x, 2), 16)).ToArray()&lt;/P&gt;&lt;P&gt;Dim hmac As HMACSHA512 = New HMACSHA512(k)&lt;/P&gt;&lt;P&gt;Dim HashedValue As Byte() = hmac.ComputeHash((New System.Text.ASCIIEncoding()).GetBytes(textToHash))&lt;BR /&gt;Return BitConverter.ToString(HashedValue).Replace("-", String.Empty)&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;Throw New Exception("HMACSHA512: " &amp;amp; ex.Message)&lt;BR /&gt;End Try&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 5 -&lt;SPAN&gt;&amp;nbsp;Compare the value of&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;transHashSHA2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with the output from the HMAC-SHA512 hash mentioned in Step 4:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dim myTransHashSha2 As String = response.transactionResponse.transHashSha2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;myTransHashSha2 should equal hashedSignatureAndMessage , but it doesn't.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where is the issue in my code? Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2019 17:56:42 GMT</pubDate>
    <dc:creator>JenHaga</dc:creator>
    <dc:date>2019-03-13T17:56:42Z</dc:date>
    <item>
      <title>Transaction Hash Upgrade Guide for API using VB.NET. Hashes don't match</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/66921#M40414</link>
      <description>&lt;P&gt;Help please. I can't get the Hash values to match.&amp;nbsp; I'm trying to follow the instructions from the API Upgrade guide here:&amp;nbsp; &lt;A href="https://developer.authorize.net/support/hash_upgrade/" target="_blank"&gt;https://developer.authorize.net/support/hash_upgrade/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 1 - I've generated my signature key and stored it in my web.config&lt;/P&gt;&lt;P&gt;Step 2 - &lt;SPAN&gt;Convert the Signature Key into a&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/byte" target="_blank" rel="noopener"&gt;byte array&lt;/A&gt;&lt;SPAN&gt;. I've skipped this step because&lt;/SPAN&gt;, "&lt;SPAN&gt;For C# users, Authorize.Net provides the following code for converting the Signature Key into a byte array and calculating the HMAC-SHA512 hash."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3 - create a message string from&amp;nbsp; the&amp;nbsp;&lt;SPAN&gt;API Login ID, the&amp;nbsp;&amp;nbsp;transaction ID and the amount.&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;I'm pulling my APILoginID from where I stored it in my web.config&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I'm pulling the transaction ID this way:&amp;nbsp;&amp;nbsp;Dim APITransID As String = response.transactionResponse.transId&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The guide says to use "The transaction amount that we send in&amp;nbsp;&lt;STRONG&gt;createTransactionResponse&amp;nbsp;&lt;/STRONG&gt;in the&amp;nbsp;&lt;STRONG&gt;amount&amp;nbsp;&lt;/STRONG&gt;element. " However, there is no amount element in response.transactionResponse, so&amp;nbsp;&lt;/SPAN&gt;I'm using the same amount variable I'm using to send in the transaction:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;Dim transactionRequest = New transactionRequestType With {&lt;BR /&gt;.transactionType = AuthOrAuthCapture,&lt;BR /&gt;.amount = amount,&lt;BR /&gt;.payment = paymentType,&lt;BR /&gt;.billTo = billingAddress,&lt;BR /&gt;.order = OrderInfo&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;So my message string looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Dim MessageString As String = String.Format("^{0}^{1}^{2}^", ApiLoginID, APITransID, amount)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 4 - "&lt;SPAN&gt;Use HMAC-SHA512 to hash the byte array form of the Signature Key from Step 2 with the message string from Step 3&lt;/SPAN&gt;" - But I'm combining step 2 &amp;amp; step 4 using the provided c# code (converted to vb):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;SignatureKey is being pulled from my web.config&lt;/LI&gt;&lt;LI&gt;I'm calling the funciton with this line:&lt;BR /&gt;Dim hashedSignatureAndMessage As String = HMACSHA512(SignatureKey, MessageString)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Function HMACSHA512(ByVal key As String, ByVal textToHash As String) As String&lt;BR /&gt;If String.IsNullOrEmpty(key) Then Throw New ArgumentNullException("HMACSHA512: key", "Parameter cannot be empty.")&lt;BR /&gt;If String.IsNullOrEmpty(textToHash) Then Throw New ArgumentNullException("HMACSHA512: textToHash", "Parameter cannot be empty.")&lt;/P&gt;&lt;P&gt;If key.Length Mod 2 &amp;lt;&amp;gt; 0 OrElse key.Trim().Length &amp;lt; 2 Then&lt;BR /&gt;Throw New ArgumentNullException("HMACSHA512: key", "Parameter cannot be odd or less than 2 characters.")&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Try&lt;BR /&gt;Dim k As Byte() = Enumerable.Range(0, key.Length).Where(Function(x) x Mod 2 = 0).[Select](Function(x) Convert.ToByte(key.Substring(x, 2), 16)).ToArray()&lt;/P&gt;&lt;P&gt;Dim hmac As HMACSHA512 = New HMACSHA512(k)&lt;/P&gt;&lt;P&gt;Dim HashedValue As Byte() = hmac.ComputeHash((New System.Text.ASCIIEncoding()).GetBytes(textToHash))&lt;BR /&gt;Return BitConverter.ToString(HashedValue).Replace("-", String.Empty)&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;Throw New Exception("HMACSHA512: " &amp;amp; ex.Message)&lt;BR /&gt;End Try&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 5 -&lt;SPAN&gt;&amp;nbsp;Compare the value of&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;transHashSHA2&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with the output from the HMAC-SHA512 hash mentioned in Step 4:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dim myTransHashSha2 As String = response.transactionResponse.transHashSha2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;myTransHashSha2 should equal hashedSignatureAndMessage , but it doesn't.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where is the issue in my code? Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 17:56:42 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/66921#M40414</guid>
      <dc:creator>JenHaga</dc:creator>
      <dc:date>2019-03-13T17:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Hash Upgrade Guide for API using VB.NET. Hashes don't match</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/66994#M40483</link>
      <description>&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/28398"&gt;@JenHaga&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;with a full disclosure that I’ve never written an app in C# when you are calculating the remainder (I think that is what you are doing with x Mod 2 = 0) you appear to be assigning a value when you need to be comparing a value. So change to Mod 2 == 0 and see what happens.</description>
      <pubDate>Sun, 17 Mar 2019 18:13:15 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/66994#M40483</guid>
      <dc:creator>Renaissance</dc:creator>
      <dc:date>2019-03-17T18:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Hash Upgrade Guide for API using VB.NET. Hashes don't match</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/67012#M40501</link>
      <description>&lt;P&gt;Thanks for your reply. Yes in c# you need == but vb uses = for both comparing and assigning. However, maybe I need to take another look at my translation from the posted c# to my vb.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 14:07:33 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/67012#M40501</guid>
      <dc:creator>JenHaga</dc:creator>
      <dc:date>2019-03-18T14:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Hash Upgrade Guide for API using VB.NET. Hashes don't match</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/67069#M40549</link>
      <description>&lt;P&gt;So there must have been something in that translation. I created a separate project in c# that held just the function copied directly from the upgrade guide. Then I published and included the .dll in my vb project. So I'm calling the function like this:&lt;/P&gt;&lt;P&gt;Dim hashedSignatureAndMessage As String = ANHMACSHA512.HMACSHA512(SignatureKey, MessageString)&lt;/P&gt;&lt;P&gt;Now the hashes are matching!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 13:38:56 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Transaction-Hash-Upgrade-Guide-for-API-using-VB-NET-Hashes-don-t/m-p/67069#M40549</guid>
      <dc:creator>JenHaga</dc:creator>
      <dc:date>2019-03-20T13:38:56Z</dc:date>
    </item>
  </channel>
</rss>

