如何计算字符串的CRC32
时间:2020-03-05 18:39:01 来源:igfitidea点击:
如何在.NET中计算字符串的CRC32(循环冗余校验和)?
解决方案
回答
这个家伙似乎有你的答案。
https://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net
如果博客消失了或者破坏了URL,那么这里是github链接:
https://github.com/damieng/DamienGKit/blob/master/CSharp/DamienG.Library/Security/Cryptography/Crc32.cs
博客文章中Crc32类的用法:
Crc32 crc32 = new Crc32(); String hash = String.Empty; using (FileStream fs = File.Open("c:\myfile.txt", FileMode.Open)) foreach (byte b in crc32.ComputeHash(fs)) hash += b.ToString("x2").ToLower(); Console.WriteLine("CRC-32 is {0}", hash);