10 décembre 2014
Cette fonction n’est pas disponible de base dans le framework .Net mais il existe une classe que vous pouvez utiliser. Il s’agit de celle développée par David Anson, visible ici sur son blog : Free hash [A reusable CRC-32 HashAlgorithm implementation for .NET]
Si vous souhaitez appeler cette classe pour obtenir le CRC32 d’un fichier vous pouvez par exemple appeler la librairie de cette façon comme le suggère cet article http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net :
private static string Hash(string filePath) { CRC32 crc32 = new CRC32(); String hash = String.Empty; using (FileStream fs = File.Open(filePath, FileMode.Open)) { foreach (byte b in crc32.ComputeHash(fs)) hash += b.ToString("x2").ToLower(); return hash; } }
Ajouter un commentaire