c sharp class for crc checksum calculator |

About CRC checksum calculus, you can also read: - C# crc checksum code for CRC-16-ANSI, CRC-CCITT, CRC-XMODEM
- C# crc checksum code for binary files
- C# crc checksum code for MODBUS RTU
A cyclic redundancy check (CRC) is an error-detecting code. It is very useful whenever there is digital communication or data transfer (together with data compression) is involved. Since during bite transmission one or more errors can occur, it is important to have some verification of transferred data validity. Idea is to treat all transferred bits as one extremely large number. Dividing this number with certain constant and obtaining the reminder, we obtain checksum byte or bytes. Practically, reminder is obtained with bitwise binary operation, without actually doing division calculus. There are different crc codes such as CRC-16 (Modbus), CRC-32, CRC-5-USB, with corresponding divisors. In order to have c sharp crc checksum calculator, we will develop C# crc checksum class for CRC-16 (Modbus). C# crc checksum class actually needs no constructor, since it can be applied many times and only one object of this class is enough. So C Sharp crc checksum class needs to have to public bytes (as the outcome of the calculus), one private integer array (data that checksum is calculated for) and one method for calculating checksum. public class crc
Calculating method has to be public and of
int_array = int_input; int_crc = int_crc ^ int_array[int_i]; int_lsb = int_crc & 0x0001; // Mask of LSB } } int_crc_byte_a = int_crc & 0x00FF; } Whole code is following: public class crc {
int_array = int_input; int_crc = int_crc ^ int_array[int_i]; int_lsb = int_crc & 0x0001; // Mask of LSB }
int_crc_byte_a = int_crc & 0x00FF; }
static void Main(string[] args)
} This class can be easily adjusted for some other check sum calculus, apart from CRC-16 (Modbus) << Previous reading Next reading >>
C Sharp CRC Checksum on lammertbies |

### Recent/Mostly Visited

Simulate recent1: IDFT Reconstruction

Simulate recent2: DFT Coefficients Calculator

Simulate recent3: Op-Amp Summing Amplifier