title: Need to create a SHA2 hash in c#
body: <p>I write a small program using the Vircurex API for trading e-currencies. Their documentation is using Ruby code examples and I am unsure of what the equivalent is in C#. For anyone interested, their documentation is listed here:</p>
  
  <p><a href="https://vircurex.com/welcome/api" rel="nofollow">https://vircurex.com/welcome/api</a></p>
  
  <p>I keep getting 8003 - Authentication failed, which I suppose means I send an incorrect SHA2 hash. They write that:</p>
  
  <p>"A SHA2 hash across a number of input values. See below details on how to calculate it"</p>
  
  <pre><code>tok = Digest::SHA2.hexdigest("#{secret_word};#{user_name};#{t};#{trx_id};create_order;sell;10;btc;50;nmc")
  </code></pre>
  
  <p>I have the following code in c#:</p>
  
  <pre><code>    public static string getHashSha256(string text)
  {
      byte[] bytes = Encoding.UTF8.GetBytes(text);
      SHA256Managed hashstring = new SHA256Managed();
      byte[] hash = hashstring.ComputeHash(bytes);
      string hashString = string.Empty;
      foreach (byte x in hash)
          hashString += String.Format("{0:x2}", x);
  
      return hashString;
  }
  </code></pre>
  
  <p>I tried to test it in the online irb at</p>
  
  <p><a href="http://tryruby.org/levels/1/challenges/0" rel="nofollow">http://tryruby.org/levels/1/challenges/0</a></p>
  
  <p>in order to see what hash the Digest::SHA2.hexdigest(".......") method would generate, but I get a </p>
  
  <pre><code>Digest::SH­A2.hexdige­st("hello"­)
  =&gt; #&lt;NameError: uninitialized constant Digest&gt;
  </code></pre>
  
  <p>So basically I don't know if it is an incorrect hash value, but I think it is. I would like to be able to test it in Ruby and also appreciate any help if there are errors in the way the C# method generates the hash.</p>