title: Result HMACSHA256 in C# different with VB.net
body: <p>I'm translating code from C# to vb.net using HMACSHA256 but the result is different when using C# and vb.net</p>
  <p>the code in vb.net</p>
  <pre><code>Imports System
  Imports System.Security.Cryptography
  Imports System.Text
                  
  Public Module Module1
      Public Sub Main()
          Console.WriteLine(hmacSHA256(&quot;Client-Id:MCH-1634273860130\nRequest-Id:425944\nRequest-Timestamp:2022-09-06T09:23:00Z\nRequest-Target:/checkout/v1/payment\nDigest:9ZhZatgEJvY4c87mSwbknmfWL9+3eS18YV6xnivYIV4=&quot;,&quot;KHUvvn4fm3zXRIip0UWY&quot;))
      End Sub
  
      Function hmacSHA256(ByVal data As String, ByVal key As String) As String
          Using hmac As HMACSHA256 = New HMACSHA256(Encoding.ASCII.GetBytes(key))
          Dim a2 As Byte() = hmac.ComputeHash(Encoding.ASCII.GetBytes(data))
          Dim a3 As String = Convert.ToBase64String(a2).ToString().Replace(&quot;+&quot;, &quot;-&quot;).Replace(&quot;/&quot;, &quot;_&quot;).Replace(&quot;=&quot;, &quot;&quot;)
          Return a3
      End Using
  End Function
      
  End Module
  </code></pre>
  <p><a href="https://dotnetfiddle.net/e95rZl" rel="nofollow noreferrer">https://dotnetfiddle.net/e95rZl</a></p>
  <p>and Writing in C#</p>
  <pre><code>using System;
  using System.Text;
  using System.Security.Cryptography;
                      
  public class Program
  {
      public static void Main()
      {
          Console.WriteLine(hmacSHA256(&quot;Client-Id:MCH-1634273860130\nRequest-Id:425944\nRequest-Timestamp:2022-09-06T09:23:00Z\nRequest-Target:/checkout/v1/payment\nDigest:9ZhZatgEJvY4c87mSwbknmfWL9+3eS18YV6xnivYIV4=&quot;,&quot;KHUvvn4fm3zXRIip0UWY&quot;));
      }
      
      private static string hmacSHA256(String data, String key)
      {
          using (HMACSHA256 hmac = new HMACSHA256(Encoding.ASCII.GetBytes(key))) {
              byte[] a2 = hmac.ComputeHash(Encoding.ASCII.GetBytes(data));
              string a3 = Convert.ToBase64String(a2).ToString().Replace(&quot;+&quot;, &quot;-&quot;).Replace(&quot;/&quot;, &quot;_&quot;).Replace(&quot;=&quot;, &quot;&quot;);
              return a3;
          }
      }
  }
  </code></pre>
  <p><a href="https://dotnetfiddle.net/JblmZD" rel="nofollow noreferrer">https://dotnetfiddle.net/JblmZD</a></p>
  <p>I already trying using PHP HMACSHA256 (it's giving same result with C#)</p>
  <p>is there any missing configuration on my VB.NET code?</p>