title: How can I calculate a CRC32 as a signed integer in C#?
body: <p>I'm a PHP developer and a little out of my element in C#. In PHP, there's a <a href="http://www.php.net/manual/en/function.crc32.php" rel="noreferrer">crc32() function</a> which returns a signed integer for any string that you pass in.</p>
  
  <p>So this is what I'm used to:</p>
  
  <pre><code>&lt;?php
  echo crc32("test");
  // displays -662733300
  </code></pre>
  
  <p>I would like to do the same thing in C#. I came across <a href="http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net" rel="noreferrer">this C# class library</a> but understand little about it. According to his instructions, I'm supposed to do this:</p>
  
  <pre><code>// first convert string to byte-array
  String input = "test";
  byte[] bytes = new byte[input.length * sizeof(char)];
  System.Buffer.BlockCopy(input.ToCharArray(), 0, bytes, 0, bytes.Length);
  
  // then calculate the value
  Crc32 crc32 = new Crc32();
  String output = "";
  foreach (byte b in crc32.ComputeHash(bytes))
  {
      output += b.ToString("x2").ToLower();
  }
  </code></pre>
  
  <p>That gives me an output string of <code>27d86d6a</code>. What do I need to do instead to return a signed integer? (Which in this example should equal <code>-662733300</code>)</p>