Click here to Skip to main content
Click here to Skip to main content

Cyclic Redundancy Check (CRC32) HashAlgorithm

By , 4 Oct 2002
 

Sample Image - CRC32_DotNet1.jpg

Sample Image - CRC32_DotNet1.jpg

Caution

As Paul Ravier mentioned, this class should NOT be used for security purposes. The CRC32 algorithm can easily be brute forced in minutes. For security applications use MD5, SHA1, SHA256, SHA384, or SHA512 in the System.Security.Cryptography namespace.

Introduction

The System.Security.Cryptography contains the HashAlgorithm. The HashAlgorithm class represents the base class from which all implementations of cryptographic hash algorithms must derive. Although I don't believe the Cyclic Redundancy Check algorithm is considered a true cryptographic hash algorithm, it does fit into the HashAlgorithm pattern.

The CRC32 algorithm is initialized using a 32-bit unsigned integer. This unsigned integer is known the polynomial. Different polynomials produce different check sums. The polynomial is used to generate a 256 element table that speeds the calculation. Normal applications will use the same polynomial throughout it's life-time. Due to this, the default behavior of the CRC32 class caches the table on first use. This behavior can be changed by setting the AutoCache property to false

Sample Usage

// Generic function using HashAlgorithm 
public void HashData(HashAlgorithm hashAlg, string str )
{
    byte[] rawBytes = System.Text.ASCIIEncoding.ASCII.GetBytes( str );
    byte[] hashData = hashAlg.ComputeHash( rawBytes );
    Console.WriteLine( BitConverter.ToString( hashData ) );
}

// Example showing that both functions can be used
public void Example()
{
    string str = "A lazy brown dog..."; // data to hash

    MD5 md5 = new MD5CryptoServiceProvider();
    HashData( md5, str); // Sample of the MD5 algorithm 

    CRC32 crc = new CRC32(); // equivalent to new CRC32(CRC32.DefaultPolynomial);
    HashData( crc, str); // Compute the default CRC32 value for a string
}

Conclusion

Although the MD5, SHA1, SHA256, SHA384, and SHA512 are more accurate than the CRC32 algorithm, sometimes you do not have a choice due various reasons. This class can be used without modification anywhere other HashAlgorithm classes can.

History

6 Oct 2002 - updated source

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Phil Bolduc
Web Developer
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberTuilindo1 Nov '10 - 5:07 
Perfect, CRC32 is exactly what I have been looking for! ... for speed up indexes in database (with MD5 indexes).
GeneralCRC32 to StringmemberMPTP2 Aug '09 - 1:19 
Hi,
 
Is there any method to get string from a CRC32 value?
QuestionWhat is the collision probabiltymemberepnetRob23 Sep '08 - 8:38 
What is the probability that any two given strings will result in the same Hash? Thanks.
QuestionEL LoggingmemberOnSeCalme17 Sep '08 - 9:37 
Hi, Phil
 
For the last couple of days, I have been researching the web for guidance on Enterprise Library Logging application block and I found your contribution in Logging on codeproject and codeplex. I downloaded the zip file and I find it very interesting. I will use it as a starting piece for my own implementation of Logging.
I have a few questions if you have a little bit of time. My public email is vancouvercancun at yahoo dot ca. Please contact me there.
Thanks
Steve
GeneralOpen Source CRC32 UtilitysussLiquid Wax1 Sep '04 - 10:08 
Hello everyone!
 
I've created an open source CRC32 utility using C# that will scan folders/directories and generate CRCs for each file (and give you a CRC for the whole set).
 
It's stable and works well. I wish to update it so that CRC numbers are generated on removable media using sectors and not through the file system.
 
http://bloodhoundcrc.sourceforge.net
GeneralFaster, faster!membercookd16 Jul '04 - 19:29 
In my tests, using the following implementation of HashCore makes your Crc32 class about 2.5 times faster.
 
protected override void HashCore(byte[] buffer, int offset, int count)
{
uint crc = m_crc;
for (int i = offset; i < offset + count; i++)
{
crc = (crc >> 8) ^ crc32Table[(crc & 0xFF) ^ buffer[i]];
}
m_crc = crc;
}

 
On my system, the original Crc32 took 10.6s to read a 400MB ISO. This one takes 3.9s.
 
And if you really want speed, you can get it down to 3.6 seconds with a bit of unsafe code:
 
unsafe protected override void HashCore(byte[] buffer, int offset, int count)
{
if (offset < 0 || buffer.Length < offset)
{
throw new ArgumentOutOfRangeException("buffer");
}
if (count < 0 || buffer.Length < offset + count)
{
throw new ArgumentOutOfRangeException("count");
}
 
fixed (byte* pCur = &buffer[offset])
{
fixed (uint* pTable = crc32Table)
{
uint crc = m_crc;
for (int i = 0; i < count; i++)
{
crc = (crc >> 8) ^ pTable[(crc & 0xFF) ^ pCur[i]];
}
m_crc = crc;
}
}
}

 
Note that pointers aren't necessarily any faster by nature. I think the extra speedup comes from not checking the array bounds each time through the loop, which saves about 10%.
 
My benchmarking shows that the unsafe version is now within 10% of the speed of the best native code version I've found. Pretty cool, eh?
GeneralRe: Faster, faster!memberHolgerK22 Jul '05 - 0:04 
I tested your code with 40 and 60 mb files.
The unsafe code is way slower than your safe code version.
But both are faster than the original.
 
But ALL are slower than the .NET MD5 implementation.
 
So at least regarding speed all stuff here is useless.
GeneralRe: Faster, faster!memberMadHatter ¢28 Mar '06 - 19:33 
take a look at the current "managed" hash functions in the framework in reflector.
 
you'll see that all their internal implementations are in an unsafe blocks, so I'd tend to believe there's a real performance gain by using them.
 



/bb|[^b]{2}/
 

GeneralModified + Tested version availablememberSteven Campbell28 Mar '04 - 10:50 
...currently included as part of the source code for my implementation of the yEnc algorithm.
 
http://www.codeproject.com/csharp/yenc.asp
[EDIT: updated link]
 
The version in my article included the following fixes:
* correctly reflected polynomial
* corrected the byte loop so that it supports non-0 offsets
* removed redundant methods
* added a set of NUnit tests
 
Thanks for the code Phil, it worked great after a little tweaking Smile | :)
GeneralRe: Modified + Tested version availablememberPhil Bolduc28 Mar '04 - 20:54 
Great, I am glad it finally worked for you. There have been so many posts regarding how it does not calculate the correct CRC for this or that. (Zip vs Ethernet, etc).
 
A yenc implementation eh? Nice. Perhaps, I'll be able to switch to a C# implmentation of my usenet downloader vs a perl one.
 
Phil

QuestionReflect ??memberAntonio Barros23 Dec '03 - 8:23 
Hello
 
i put the "Reflect" in the code, but i've error in compilation.
What happen ?
 
More:
 
Is it necessary to make this: ((hash.Length / 8) ? Why?
StringBuilder sb = new StringBuilder(hash.Length * 2 + (hash.Length / 8));
 
Thank you in advance
A.Barros
GeneralThis CRC32 algorithm is brokenmembercbruun18 Dec '03 - 10:20 
This algorith does not calculate the CRC32 as defined by CCITT. As I see it the table generation code is wrong - it will only create values with upper nibble = 0 which leads to all CRC's having upper nibble = F which obviously is wrong.
 
Unfortunately I do not have the code or theory for the table generation but the correct table is
(as defined in assembler where i once implemented it, LONG does put the left byte in highest address, so longs can be read directly)
 
Crc32_Table: LONG 000h,000h,000h,000h ; 00
LONG 077h,007h,030h,096h
LONG 0eeh,00eh,061h,02ch
LONG 099h,009h,051h,0bah
 
LONG 007h,06dh,0c4h,019h ; 04
LONG 070h,06ah,0f4h,08fh
LONG 0e9h,063h,0a5h,035h
LONG 09eh,064h,095h,0a3h
 
LONG 00eh,0dbh,088h,032h ; 08
LONG 079h,0dch,0b8h,0a4h
LONG 0e0h,0d5h,0e9h,01eh
LONG 097h,0d2h,0d9h,088h
 
LONG 009h,0b6h,04ch,02bh ; 0c
LONG 07eh,0b1h,07ch,0bdh
LONG 0e7h,0b8h,02dh,007h
LONG 090h,0bfh,01dh,091h
 
LONG 01dh,0b7h,010h,064h ; 10
LONG 06ah,0b0h,020h,0f2h
LONG 0f3h,0b9h,071h,048h
LONG 084h,0beh,041h,0deh
 
LONG 01ah,0dah,0d4h,07dh ; 14
LONG 06dh,0ddh,0e4h,0ebh
LONG 0f4h,0d4h,0b5h,051h
LONG 083h,0d3h,085h,0c7h
 
LONG 013h,06ch,098h,056h ; 18
LONG 064h,06bh,0a8h,0c0h
LONG 0fdh,062h,0f9h,07ah
LONG 08ah,065h,0c9h,0ech
 
LONG 014h,001h,05ch,04fh ; 1c
LONG 063h,006h,06ch,0d9h
LONG 0fah,00fh,03dh,063h
LONG 08dh,008h,00dh,0f5h
 
LONG 03bh,06eh,020h,0c8h ; 20
LONG 04ch,069h,010h,05eh
LONG 0d5h,060h,041h,0e4h
LONG 0a2h,067h,071h,072h
 
LONG 03ch,003h,0e4h,0d1h ; 24
LONG 04bh,004h,0d4h,047h
LONG 0d2h,00dh,085h,0fdh
LONG 0a5h,00ah,0b5h,06bh
 
LONG 035h,0b5h,0a8h,0fah ; 28
LONG 042h,0b2h,098h,06ch
LONG 0dbh,0bbh,0c9h,0d6h
LONG 0ach,0bch,0f9h,040h
 
LONG 032h,0d8h,06ch,0e3h ; 2c
LONG 045h,0dfh,05ch,075h
LONG 0dch,0d6h,00dh,0cfh
LONG 0abh,0d1h,03dh,059h
 
LONG 026h,0d9h,030h,0ach ; 30
LONG 051h,0deh,000h,03ah
LONG 0c8h,0d7h,051h,080h
LONG 0bfh,0d0h,061h,016h
 
LONG 021h,0b4h,0f4h,0b5h ; 34
LONG 056h,0b3h,0c4h,023h
LONG 0cfh,0bah,095h,099h
LONG 0b8h,0bdh,0a5h,00fh
 
LONG 028h,002h,0b8h,09eh ; 38
LONG 05fh,005h,088h,008h
LONG 0c6h,00ch,0d9h,0b2h
LONG 0b1h,00bh,0e9h,024h
 
LONG 02fh,06fh,07ch,087h ; 3c
LONG 058h,068h,04ch,011h
LONG 0c1h,061h,01dh,0abh
LONG 0b6h,066h,02dh,03dh
 
LONG 076h,0dch,041h,090h ; 40
LONG 001h,0dbh,071h,006h
LONG 098h,0d2h,020h,0bch
LONG 0efh,0d5h,010h,02ah
 
LONG 071h,0b1h,085h,089h ; 44
LONG 006h,0b6h,0b5h,01fh
LONG 09fh,0bfh,0e4h,0a5h
LONG 0e8h,0b8h,0d4h,033h
 
LONG 078h,007h,0c9h,0a2h ; 48
LONG 00fh,000h,0f9h,034h
LONG 096h,009h,0a8h,08eh
LONG 0e1h,00eh,098h,018h
 
LONG 07fh,06ah,00dh,0bbh ; 4c
LONG 008h,06dh,03dh,02dh
LONG 091h,064h,06ch,097h
LONG 0e6h,063h,05ch,001h
 
LONG 06bh,06bh,051h,0f4h ; 50
LONG 01ch,06ch,061h,062h
LONG 085h,065h,030h,0d8h
LONG 0f2h,062h,000h,04eh
 
LONG 06ch,006h,095h,0edh ; 54
LONG 01bh,001h,0a5h,07bh
LONG 082h,008h,0f4h,0c1h
LONG 0f5h,00fh,0c4h,057h
 
LONG 065h,0b0h,0d9h,0c6h ; 58
LONG 012h,0b7h,0e9h,050h
LONG 08bh,0beh,0b8h,0eah
LONG 0fch,0b9h,088h,07ch
 
LONG 062h,0ddh,01dh,0dfh ; 5c
LONG 015h,0dah,02dh,049h
LONG 08ch,0d3h,07ch,0f3h
LONG 0fbh,0d4h,04ch,065h
 
LONG 04dh,0b2h,061h,058h ; 60
LONG 03ah,0b5h,051h,0ceh
LONG 0a3h,0bch,000h,074h
LONG 0d4h,0bbh,030h,0e2h
 
LONG 04ah,0dfh,0a5h,041h ; 64
LONG 03dh,0d8h,095h,0d7h
LONG 0a4h,0d1h,0c4h,06dh
LONG 0d3h,0d6h,0f4h,0fbh
 
LONG 043h,069h,0e9h,06ah ; 68
LONG 034h,06eh,0d9h,0fch
LONG 0adh,067h,088h,046h
LONG 0dah,060h,0b8h,0d0h
 
LONG 044h,004h,02dh,073h ; 6c
LONG 033h,003h,01dh,0e5h
LONG 0aah,00ah,04ch,05fh
LONG 0ddh,00dh,07ch,0c9h
 
LONG 050h,005h,071h,03ch ; 70
LONG 027h,002h,041h,0aah
LONG 0beh,00bh,010h,010h
LONG 0c9h,00ch,020h,086h
 
LONG 057h,068h,0b5h,025h ; 74
LONG 020h,06fh,085h,0b3h
LONG 0b9h,066h,0d4h,009h
LONG 0ceh,061h,0e4h,09fh
 
LONG 05eh,0deh,0f9h,00eh ; 78
LONG 029h,0d9h,0c9h,098h
LONG 0b0h,0d0h,098h,022h
LONG 0c7h,0d7h,0a8h,0b4h
 
LONG 059h,0b3h,03dh,017h ; 7c
LONG 02eh,0b4h,00dh,081h
LONG 0b7h,0bdh,05ch,03bh
LONG 0c0h,0bah,06ch,0adh
 
LONG 0edh,0b8h,083h,020h ; 80
LONG 09ah,0bfh,0b3h,0b6h
LONG 003h,0b6h,0e2h,00ch
LONG 074h,0b1h,0d2h,09ah
 
LONG 0eah,0d5h,047h,039h ; 84
LONG 09dh,0d2h,077h,0afh
LONG 004h,0dbh,026h,015h
LONG 073h,0dch,016h,083h
 
LONG 0e3h,063h,00bh,012h ; 88
LONG 094h,064h,03bh,084h
LONG 00dh,06dh,06ah,03eh
LONG 07ah,06ah,05ah,0a8h
 
LONG 0e4h,00eh,0cfh,00bh ; 8c
LONG 093h,009h,0ffh,09dh
LONG 00ah,000h,0aeh,027h
LONG 07dh,007h,09eh,0b1h
 
LONG 0f0h,00fh,093h,044h ; 90
LONG 087h,008h,0a3h,0d2h
LONG 01eh,001h,0f2h,068h
LONG 069h,006h,0c2h,0feh
 
LONG 0f7h,062h,057h,05dh ; 94
LONG 080h,065h,067h,0cbh
LONG 019h,06ch,036h,071h
LONG 06eh,06bh,006h,0e7h
 
LONG 0feh,0d4h,01bh,076h ; 98
LONG 089h,0d3h,02bh,0e0h
LONG 010h,0dah,07ah,05ah
LONG 067h,0ddh,04ah,0cch
 
LONG 0f9h,0b9h,0dfh,06fh ; 9c
LONG 08eh,0beh,0efh,0f9h
LONG 017h,0b7h,0beh,043h
LONG 060h,0b0h,08eh,0d5h
 
LONG 0d6h,0d6h,0a3h,0e8h ; a0
LONG 0a1h,0d1h,093h,07eh
LONG 038h,0d8h,0c2h,0c4h
LONG 04fh,0dfh,0f2h,052h
 
LONG 0d1h,0bbh,067h,0f1h ; a4
LONG 0a6h,0bch,057h,067h
LONG 03fh,0b5h,006h,0ddh
LONG 048h,0b2h,036h,04bh
 
LONG 0d8h,00dh,02bh,0dah ; a8
LONG 0afh,00ah,01bh,04ch
LONG 036h,003h,04ah,0f6h
LONG 041h,004h,07ah,060h
 
LONG 0dfh,060h,0efh,0c3h ; ac
LONG 0a8h,067h,0dfh,055h
LONG 031h,06eh,08eh,0efh
LONG 046h,069h,0beh,079h
 
LONG 0cbh,061h,0b3h,08ch ; b0
LONG 0bch,066h,083h,01ah
LONG 025h,06fh,0d2h,0a0h
LONG 052h,068h,0e2h,036h
 
LONG 0cch,00ch,077h,095h ; b4
LONG 0bbh,00bh,047h,003h
LONG 022h,002h,016h,0b9h
LONG 055h,005h,026h,02fh
 
LONG 0c5h,0bah,03bh,0beh ; b8
LONG 0b2h,0bdh,00bh,028h
LONG 02bh,0b4h,05ah,092h
LONG 05ch,0b3h,06ah,004h
 
LONG 0c2h,0d7h,0ffh,0a7h ; bc
LONG 0b5h,0d0h,0cfh,031h
LONG 02ch,0d9h,09eh,08bh
LONG 05bh,0deh,0aeh,01dh
 
LONG 09bh,064h,0c2h,0b0h ; c0
LONG 0ech,063h,0f2h,026h
LONG 075h,06ah,0a3h,09ch
LONG 002h,06dh,093h,00ah
 
LONG 09ch,009h,006h,0a9h ; c4
LONG 0ebh,00eh,036h,03fh
LONG 072h,007h,067h,085h
LONG 005h,000h,057h,013h
 
LONG 095h,0bfh,04ah,082h ; c8
LONG 0e2h,0b8h,07ah,014h
LONG 07bh,0b1h,02bh,0aeh
LONG 00ch,0b6h,01bh,038h
 
LONG 092h,0d2h,08eh,09bh ; cc
LONG 0e5h,0d5h,0beh,00dh
LONG 07ch,0dch,0efh,0b7h
LONG 00bh,0dbh,0dfh,021h
 
LONG 086h,0d3h,0d2h,0d4h ; d0
LONG 0f1h,0d4h,0e2h,042h
LONG 068h,0ddh,0b3h,0f8h
LONG 01fh,0dah,083h,06eh
 
LONG 081h,0beh,016h,0cdh ; d4
LONG 0f6h,0b9h,026h,05bh
LONG 06fh,0b0h,077h,0e1h
LONG 018h,0b7h,047h,077h
 
LONG 088h,008h,05ah,0e6h ; d8
LONG 0ffh,00fh,06ah,070h
LONG 066h,006h,03bh,0cah
LONG 011h,001h,00bh,05ch
 
LONG 08fh,065h,09eh,0ffh ; dc
LONG 0f8h,062h,0aeh,069h
LONG 061h,06bh,0ffh,0d3h
LONG 016h,06ch,0cfh,045h
 
LONG 0a0h,00ah,0e2h,078h ; e0
LONG 0d7h,00dh,0d2h,0eeh
LONG 04eh,004h,083h,054h
LONG 039h,003h,0b3h,0c2h
 
LONG 0a7h,067h,026h,061h ; e4
LONG 0d0h,060h,016h,0f7h
LONG 049h,069h,047h,04dh
LONG 03eh,06eh,077h,0dbh
 
LONG 0aeh,0d1h,06ah,04ah ; e8
LONG 0d9h,0d6h,05ah,0dch
LONG 040h,0dfh,00bh,066h
LONG 037h,0d8h,03bh,0f0h
 
LONG 0a9h,0bch,0aeh,053h ; ec
LONG 0deh,0bbh,09eh,0c5h
LONG 047h,0b2h,0cfh,07fh
LONG 030h,0b5h,0ffh,0e9h
 
LONG 0bdh,0bdh,0f2h,01ch ; f0
LONG 0cah,0bah,0c2h,08ah
LONG 053h,0b3h,093h,030h
LONG 024h,0b4h,0a3h,0a6h
 
LONG 0bah,0d0h,036h,005h ; f4
LONG 0cdh,0d7h,006h,093h
LONG 054h,0deh,057h,029h
LONG 023h,0d9h,067h,0bfh
 
LONG 0b3h,066h,07ah,02eh ; f8
LONG 0c4h,061h,04ah,0b8h
LONG 05dh,068h,01bh,002h
LONG 02ah,06fh,02bh,094h
 
LONG 0b4h,00bh,0beh,037h ; fc
LONG 0c3h,00ch,08eh,0a1h
LONG 05ah,005h,0dfh,01bh
LONG 02dh,002h,0efh,08dh
Regards
Claus

GeneralRe: This CRC32 algorithm is brokenmembercbruun18 Dec '03 - 12:51 
I found the error.
 
The polynomial must be reflected (mirrored hibit-lowbit) before table generation.
 
Correct code is
 

private static uint Reflect(uint val)
{
	uint oval = 0;
	for (int i=0; i<32; i++)
	{
		oval = (oval<<1) + (val&1);
		val >>= 1;
	}
	return oval;
}

 
protected static uint[] BuildCRC32Table( uint ulPolynomial )
{
	uint dwCrc;
	uint[] table = new uint[256];
 
	ulPolynomial = Reflect(ulPolynomial);
 
	// 256 values representing ASCII character codes. 
	for (int i = 0; i < 256; i++)
	{
		dwCrc = (uint)i;
		for (int j = 8; j > 0; j--)
		{
			if((dwCrc & 1) == 1)
				dwCrc = (dwCrc >> 1) ^ ulPolynomial;
			else
				dwCrc >>= 1;
		}
		table[i] = dwCrc;
	}
	return table;
}

GeneralRe: This CRC32 algorithm is brokenmemberSteven Campbell28 Mar '04 - 9:35 

In addition, the loop line inside of HashCore should be:

for (int i = offset; i < offset + count; i++)

GeneralRe: This CRC32 algorithm is brokenmemberPhil Bolduc28 Mar '04 - 20:56 
I will have to find some time to update the source with the corrections listed here. Sorry for any inconvience fellow Code Project users.
 
Phil

GeneralRe: This CRC32 algorithm is brokenmemberVitaly Rudchenko7 May '07 - 0:54 
To fix the problem insert Initialize() into begin of ComputeHash function.
GeneralRe: This CRC32 algorithm is brokenmemberron wilson7 Sep '05 - 11:38 
this solution is the same as setting your default polynomial to the 'official' pkzip value, 0xEDB88320, i.e. Reflect(0xEDB88320) = 0x04C11DB7. also, using the default polynomial and its reflection gives different hash results.
GeneralRe: This CRC32 algorithm is brokenmemberWillemM3 May '04 - 21:22 
255 | 255 = True
191 | 244 = False
16 | 225 = False
192 | 218 = False
 
I got this result from a simple hashing.
I hashed the same text twice, and the result is not equal.
 
I am sorry, but your hash sure is broken.
 
Greetings.... Smile | :)


GeneralRe: This CRC32 algorithm is brokenmembercbruun10 May '04 - 4:57 
Willem,
 
What are you referring to ? The table I published or ... ?
 
Regards
Claus
GeneralRe: This CRC32 algorithm is brokenmemberWillemM10 May '04 - 5:07 
If I hash the text "Compad 5" two times, I get different results using your CRC32 CryptoService Provider.
 
Greetings.... Smile | :)


Questionnew public byte[] ComputeHash ---&gt; necessary?membercuynen20 Nov '03 - 7:46 
redefining ComputeHash and all its overloads isn't necessary
 
HashAlgorithm contains implementations which internally use
+ Initialize
+ HashCore
+ HashFinal
 
nevertheless, you could still override ComputeHash, e.g. to optimize a Stream buffer
GeneralCRC calcsmemberTim Kohler21 Oct '03 - 4:00 
Hey, I've always used CRCs to do data validation checks on both ends of a communications channel.
You can CRC on the send end and send the value to the client along with the data. The client can then CRC and if the values match you can be very sure (althought not 100%) you got good data. If the client calc's a different CRC than the server's value you need to have the server resend.
 
I think CRC is used for this purpose, not cryptography.
 

GeneralClarification of statementmemberTom Archer9 Sep '03 - 9:44 
You make the following point in your Conclusion:
 
Although the MD5, SHA1, SHA256, SHA384, and SHA512 are more accurate than the CRC32 algorithm, sometimes you do not have a choice due various reasons. This class can be used without modification anywhere other HashAlgorithm classes can.
 
What are examples of these situations?
 
Cheers,
Tom Archer
Inside C#,
Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
GeneralRe: Clarification of statementmemberMika15 Dec '03 - 10:25 
Well I can think of one off the top of my head - Integrating some code with current code - for example when you ZIP some files, the ZIP stores the CRC's of the compressed files to check whether they have been corrupted after un-zipping.
 
Maybe not used for security but definitely has a place.

 
Mladen Mihajlovic
http://mladen.nata.co.za

QuestionHow I could hash a file?memberdomain_gr19 Jun '03 - 3:13 
Please tell me how I could hash a file using C# code.
 
Thank you... Smile | :)
 
Reply at dkolettis@Symmetrics.gr
 
Dimitris

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 5 Oct 2002
Article Copyright 2002 by Phil Bolduc
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid