<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculating CRC-32 in C# and .NET</title>
	<atom:link href="http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net/feed" rel="self" type="application/rss+xml" />
	<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=calculating_crc32_in_c_and_net</link>
	<description>A .NET developer in silicon valley</description>
	<lastBuildDate>Wed, 11 Apr 2012 18:41:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-46848</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Wed, 02 Nov 2011 19:50:03 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-46848</guid>
		<description>If you want to ensure file integrity, sure, SHA256 is a great choice, but some people need to calculate a CRC32 for backwards compatibility with things like ZIP.

[)amien</description>
		<content:encoded><![CDATA[<p>If you want to ensure file integrity, sure, SHA256 is a great choice, but some people need to calculate a CRC32 for backwards compatibility with things like ZIP.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Doe</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-46845</link>
		<dc:creator>John Doe</dc:creator>
		<pubDate>Wed, 02 Nov 2011 17:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-46845</guid>
		<description>I may be missing something, but why not use System.Security.Cryptography.SHA256 instead if all you need is to verify file integrity?</description>
		<content:encoded><![CDATA[<p>I may be missing something, but why not use System.Security.Cryptography.SHA256 instead if all you need is to verify file integrity?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-44913</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Tue, 29 Mar 2011 14:49:19 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-44913</guid>
		<description>It produces a 32-bit CRC (hence the name).  If you display this as hexadecimal then each pair of two hex letters is 8 bits. Four of these pairs gives 32-bits.

[)amien</description>
		<content:encoded><![CDATA[<p>It produces a 32-bit CRC (hence the name).  If you display this as hexadecimal then each pair of two hex letters is 8 bits. Four of these pairs gives 32-bits.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ibram</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-44911</link>
		<dc:creator>ibram</dc:creator>
		<pubDate>Tue, 29 Mar 2011 13:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-44911</guid>
		<description>Thank you for the code.
I made some performance tests, that could be interesting.
For a 55MB text file:
System.Security.Cryptography.SHA256 needs 779 ms.
System.Security.Cryptography.MD5 needs 144 ms.
CRC32 needs 660 ms.

Is it correct that the crc is just a 8 character string?

I tried to use the Create() method, but than realized that this creates the SHA1Managed object.
Crc32.Create().ComputeHash( fs )

Than I put this in your code:
public new static Crc32 Create()
{
    return new Crc32();
}</description>
		<content:encoded><![CDATA[<p>Thank you for the code.<br />
I made some performance tests, that could be interesting.<br />
For a 55MB text file:<br />
System.Security.Cryptography.SHA256 needs 779 ms.<br />
System.Security.Cryptography.MD5 needs 144 ms.<br />
CRC32 needs 660 ms.</p>
<p>Is it correct that the crc is just a 8 character string?</p>
<p>I tried to use the Create() method, but than realized that this creates the SHA1Managed object.<br />
Crc32.Create().ComputeHash( fs )</p>
<p>Than I put this in your code:<br />
public new static Crc32 Create()<br />
{<br />
    return new Crc32();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-41815</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Fri, 14 May 2010 21:02:41 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-41815</guid>
		<description>You&#039;ll see it inherits from the HashAlgorithm class which has a ComputeHash method that takes a Stream object, reads 4K blocks at a time and calls through to HashCore for each block.

[)amien</description>
		<content:encoded><![CDATA[<p>You&#8217;ll see it inherits from the HashAlgorithm class which has a ComputeHash method that takes a Stream object, reads 4K blocks at a time and calls through to HashCore for each block.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chizl</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-41814</link>
		<dc:creator>Chizl</dc:creator>
		<pubDate>Fri, 14 May 2010 20:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-41814</guid>
		<description>In your example you have:
using (FileStream fs = File.Open(&quot;c:\\myfile.txt&quot;, FileMode.Open))
       foreach (byte b in crc32.Compute(fs)) hash += b.ToString(&quot;x2&quot;).ToLower();

However the only Compute mehtods I see are static and none of them take a FileStream object.</description>
		<content:encoded><![CDATA[<p>In your example you have:<br />
using (FileStream fs = File.Open(&#8220;c:\\myfile.txt&#8221;, FileMode.Open))<br />
       foreach (byte b in crc32.Compute(fs)) hash += b.ToString(&#8220;x2&#8243;).ToLower();</p>
<p>However the only Compute mehtods I see are static and none of them take a FileStream object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phooey</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-39546</link>
		<dc:creator>Phooey</dc:creator>
		<pubDate>Thu, 08 Apr 2010 08:20:20 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-39546</guid>
		<description>If you interpret size as being the size of the array, yes, but the array already has a length, why would you need to pass it in again?

When passing the array, an offset and size, size refers to the size of the data, see the parameter definition for the HashCore function of the HashAlgorithm:

cbSize:
    The number of bytes in the byte array to use as data

Cheers,
Phooey.</description>
		<content:encoded><![CDATA[<p>If you interpret size as being the size of the array, yes, but the array already has a length, why would you need to pass it in again?</p>
<p>When passing the array, an offset and size, size refers to the size of the data, see the parameter definition for the HashCore function of the HashAlgorithm:</p>
<p>cbSize:<br />
    The number of bytes in the byte array to use as data</p>
<p>Cheers,<br />
Phooey.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-39472</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Wed, 07 Apr 2010 15:54:30 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-39472</guid>
		<description>That is intentional - start is an index into the buffer to start populating at. If you change the loop as you describe it will go out of bounds with a non-zero value of start.

[)amien</description>
		<content:encoded><![CDATA[<p>That is intentional &#8211; start is an index into the buffer to start populating at. If you change the loop as you describe it will go out of bounds with a non-zero value of start.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phooey</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-39464</link>
		<dc:creator>Phooey</dc:creator>
		<pubDate>Wed, 07 Apr 2010 14:53:24 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-39464</guid>
		<description>Thanks for the code, there&#039;s a little bug in the CalculateHash function:

for(int i = start; i &lt; size; i++)

needs to be:

for(int i = start; i &lt; size+start; i++)

else you wont hash the whole buffer for non-zero values of start.

Cheers,
Phooey.</description>
		<content:encoded><![CDATA[<p>Thanks for the code, there&#8217;s a little bug in the CalculateHash function:</p>
<p>for(int i = start; i &lt; size; i++)</p>
<p>needs to be:</p>
<p>for(int i = start; i &lt; size+start; i++)</p>
<p>else you wont hash the whole buffer for non-zero values of start.</p>
<p>Cheers,<br />
Phooey.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ASP.NET Performance - Part 3 - Cache Busting - Karl Seguin - CodeBetter.Com - Stuff you need to Code Better!</title>
		<link>http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net#comment-34252</link>
		<dc:creator>ASP.NET Performance - Part 3 - Cache Busting - Karl Seguin - CodeBetter.Com - Stuff you need to Code Better!</dc:creator>
		<pubDate>Mon, 11 Jan 2010 13:53:45 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/08/08/calculating_crc32_in_c_and_net.aspx#comment-34252</guid>
		<description>[...] of our asset folder) and hash values. For my &quot;hash&quot; I&#039;m using a CRC32, specifically Damien Guard&#039;s C# implementation. The nice thing about CRC32 is that we end up with pretty small values. The downside is that [...]</description>
		<content:encoded><![CDATA[<p>[...] of our asset folder) and hash values. For my &quot;hash&quot; I&#39;m using a CRC32, specifically Damien Guard&#39;s C# implementation. The nice thing about CRC32 is that we end up with pretty small values. The downside is that [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.240 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-17 08:46:43 -->
<!-- Compression = gzip -->
