title: String with Convert.ToChar(0) hash result different than chr(0) in PHP when hashed hash_hmac
body: <p>I have a string in PHP which is being converted to a byte array and hashed.</p>
  
  <p>The string being converted to the byte array looks like:</p>
  
  <p>"g". chr(0) . "poo";</p>
  
  <p>I need to equivalent byte array in C# so i can get the same hash..</p>
  
  <p>EDIT: Here is the FULL problem, resulting hash is not the same.</p>
  
  <p>PHP</p>
  
  <pre><code>$api_secret = '5432919427bd18884fc2a6e48b65dfba48fd9a1a46e3468b52fadbc6d6b463425';
  $data = 'payment_currency=USD&amp;group_orders=0&amp;count=100&amp;nonce=1385689989977529';
  $endpoint = '/info/orderbook';
  
  $signature = hash_hmac('sha512', $endpoint . chr(0) . $data, $api_secret);
  
  $result =  base64_encode($signature);
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>var apiSecret = "5432919427bd18884fc2a6e48b65dfba48fd9a1a46e3468b52fadbc6d6b463425";
  var data = "payment_currency=USD&amp;group_orders=0&amp;count=100&amp;nonce=1385689989977529";
  var endPoint = "/info/orderbook";
  
  System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
  
  String message = endpPoint + Convert.ToChar(0) + data;
  
  var hmacsha512 = new HMACSHA512(encoding.GetBytes(message));
  var result = Convert.ToBase64String(hmacsha512.Hash);
  </code></pre>
  
  <p>I've tried different base64 encoding like:</p>
  
  <pre><code>public static string ByteToString(byte[] buff)
      {
          string sbinary = "";
          for (int i = 0; i &lt; buff.Length; i++)
              sbinary += buff[i].ToString("X2"); /* hex format */
          return sbinary;
      }   
  </code></pre>
  
  <p>but ultimately the issue appears to be the byteArray that is hashed because of the chr(0) php uses.</p>