Skip lines and Calculate CRC32 checksum using c#

This article will explains about how to calculate checksum of text file using famous method i.e., CRC32.NET

The requirements will be like this you have text file or csv file, in that you want to skip line(s) to calculate checksum value using stream reader in efficiient way.

For that we will see the how to do that in the below code.

Install CRC32.NET Package from nuget


checksum line to skip,4c2750bd

Here file has two lines and we want to skip the first line and calculate the actual checksum value.

C# Code

class Program
        static void Main(string[] args)
            Console.WriteLine("Welcome to CRC32 DEMO !!\n");

            //Object initialization
            var crc32 = new Crc32Algorithm();

            String hash = String.Empty;
            using (Stream fs1 = File.Open(@"D:\Test\file1.txt", FileMode.Open)) //here you pass the file name 
                using (StreamReader sr = new StreamReader(fs1))
                    var temp = sr.ReadLine();//skip first line
                    var data = sr.ReadToEnd();//reading data from next line
                    byte[] plainText = Encoding.UTF8.GetBytes(data);
                    foreach (byte b in crc32.ComputeHash(plainText))
                        hash += b.ToString("x2").ToLower();
            Console.WriteLine("CRC-32 is {0}", hash);


Labels:, crc32, csv file checksum using crc32, skip line in stream reader, skip and calculate checksum, file checksum using

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker