title: Get a file SHA256 Hash code and Checksum
body: <p>Previously I asked a <a href="https://stackoverflow.com/questions/38459428/use-a-combination-of-sha1md5">question</a> about combining SHA1+MD5 but after that I understand calculating SHA1 and then MD5 of a lagrge file is not that faster than SHA256.
  In my case a 4.6 GB file takes about 10 mins with the default implementation SHA256 with (C# MONO) in a Linux system.</p>
  <pre><code>public static string GetChecksum(string file)
  {
      using (FileStream stream = File.OpenRead(file))
      {
          var sha = new SHA256Managed();
          byte[] checksum = sha.ComputeHash(stream);
          return BitConverter.ToString(checksum).Replace(&quot;-&quot;, String.Empty);
      }
  }
  </code></pre>
  <p>Then I read <a href="https://stackoverflow.com/questions/1177607/what-is-the-fastest-way-to-create-a-checksum-for-large-files-in-c-sharp">this topic</a> and somehow change my code according what they said to :</p>
  <pre><code>public static string GetChecksumBuffered(Stream stream)
  {
      using (var bufferedStream = new BufferedStream(stream, 1024 * 32))
      {
          var sha = new SHA256Managed();
          byte[] checksum = sha.ComputeHash(bufferedStream);
          return BitConverter.ToString(checksum).Replace(&quot;-&quot;, String.Empty);
      }
  }
  </code></pre>
  <p>But It doesn't have such a affection and takes about 9 mins.</p>
  <p>Then I try to test my file through <code>sha256sum</code> command in Linux for the same file and It takes about 28 secs and both the above code and Linux command give the same result !</p>
  <p>Someone advised me to read about differences between Hash Code and Checksum and I reach to <a href="https://stackoverflow.com/questions/460576/hash-code-and-checksum-whats-the-difference">this topic</a> that explains the differences.</p>
  <p>My Questions are :</p>
  <ol>
  <li><p>What causes such different between the above code and Linux <code>sha256sum</code> in time ?</p>
  </li>
  <li><p>What does the above code do ? (I mean is it the hash code calculation or checksum calculation? Because if you search about give a hash code of a file and checksum of a file in C#, they both reach to the above code.)</p>
  </li>
  <li><p>Is there any motivated attack against <code>sha256sum</code> even when SHA256 is collision resistant ?</p>
  </li>
  <li><p>How can I make my implementation as fast as <code>sha256sum</code> in C#?</p>
  </li>
  </ol>