Questions tagged [crc16]

CRC16 is a 16-bit Cyclic Redundancy Check code, used mainly as an error detection method during data transmission.

A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents; on retrieval the calculation is repeated, and corrective action can be taken against presumed data corruption if the check values do not match. Because the check value has a fixed length, the function that generates it is occasionally used as a hash function.wikipedia

The most commonly used polynomial lengths are:

  • CRC-8: 9 bits
  • CRC-16: 17 bits
  • CRC-32: 33 bits
  • CRC-64: 65 bits

A truly excellent tutorial on CRC's is Ross Williams' "Painless Guide to CRC Detection Algorithms", which can also be found here, here, here, here, and here.

323 questions
2
votes
2 answers

Extract certain byte from char array and byte array in java

I have an char array containing hex value. It contains 6 bytes. I have calculated the crc of these 6 bytes and the function returns int value. This is the code. char buffer[] = {0x01,0x05,0x00,0x06,0x00,0x00}; byte[] bufferbyte = new…
user3048644
  • 93
  • 1
  • 5
  • 17
2
votes
4 answers

Calculate 16 bit CRC in java and append it at the end of the byte array

I have the following buffer byte pingBuff[] ={0x01, 0x01,0x00,0x01,0x00,0x20} I need to calculate 16 bit CRC of these 6 bytes and append it at the end of the pingBuff[] I have done it using C++ and tried to change that code in java like below but…
user3048644
  • 93
  • 1
  • 5
  • 17
2
votes
2 answers

NSData to CRC-16?

I am trying to to calculate CRC-16 from NSData. It is not working, I am expecting "BB3D" from 123456789, but I get nothing like it. This is the code that I have: static const unsigned short crc16table[] = { 0x0000, 0xC0C1, 0xC181, 0x0140,…
Shield
  • 123
  • 1
  • 2
  • 5
2
votes
4 answers

What is the possibility of CRC16 collisions on 20 bytes of data?

I am developing a system which needs to store a hash for a structure 20 bytes maybe less in length. However, in order to optimize the process of looking up the hash in a series of hashes, we want to reduce the size of the hash as much as…
Jeremy
  • 824
  • 1
  • 9
  • 21
2
votes
5 answers

Progress 10.1C 4GL Encode Function

Does anyone know which algorithm Progress 10.1C uses in the Encode Function? I found this: http://knowledgebase.progress.com/articles/Article/21685 The Progress 4GL ENCODE function uses a CRC-16 algorithm to generate its encoded output. Progress…
RaphaelH
  • 2,144
  • 2
  • 30
  • 43
2
votes
3 answers

Translate Matlab code to Python

I have a problem with this algorithm: function crc16 = crc16eval(D) % CRC16EVAL CRC-CCITT check with the polynomial: x^16+x^12+x^5+1 D = uint16(D); crchi = 255; crclo = 255; t =…
antonio
  • 540
  • 1
  • 5
  • 19
1
vote
4 answers

crc16 algorithm from C++ to bash

I am trying to implement a CRC16 checksum in bash. I'm porting from an existing piece of C++ code. I'm almost there, but I am getting different answers. I don't quite see why the checksums between the C++ code and the bash script are…
jasonmclose
  • 1,667
  • 4
  • 22
  • 38
1
vote
1 answer

Implementing Custom CRC-16 in Python to Replicate MATLAB's comm.CRCGenerator Behavior

I am trying to replicate a custom CRC-16 algorithm implemented in MATLAB, in Python. The original MATLAB code uses the comm.CRCGenerator object with the polynomial 'X^16 + X^12 + X^5 + 1'. The MATLAB code and its output are as…
deepIglicious
  • 33
  • 1
  • 8
1
vote
1 answer

Data Transmission CRC, differentiation of CRC/FALSE

I'm trying to learn CRCs. Yet- I have no clue what a CRC16/CCITT_FALSE standard is. Can anyone help or send some resources that can explain the difference between CRC-16-CCITT and CRC16/CCITT FALSE is?
1
vote
2 answers

C# to F# CRC16 ^ and ^^^ works different. How ^ works?

I found this C# code for CRC16 but I need it on F# : using System; public class Crc16 { const ushort polynomial = 0xA001; ushort[] table = new ushort[256]; public ushort ComputeChecksum(byte[] bytes) { ushort crc = 0; …
cnd
  • 32,616
  • 62
  • 183
  • 313
1
vote
2 answers

Calculating CRC16 on Vec

I'm sending and receiving raw binary data via the serial port, so I have a predefined message stored in a u8 vector. I need to calculate the 16bit CRC and append that onto the end before sending it, however I keep running into issues with casting…
birdistheword99
  • 179
  • 1
  • 15
1
vote
1 answer

Checksum/CRC reverse engineering of Microsoft NDIS packet

I am trying to decode a 42-byte packet which seems to include 2-byte CRC / checksum field This is a Microsoft NDIS packet (type IPX) which is sent in HLK (WHQL) tests I have decoded most parts of the NDIS header but I can't seem to figure out the…
Amit
  • 165
  • 1
  • 9
1
vote
1 answer

Cyclic Redundancy check : Single and double bit error

Found this in the book by Forouzan (Data Communications and Networking 5E). But, not able to understand the logic behind this. This is in the context of topic two isolated single-bit errors In other words, g(x) must not divide x^t + 1, where t is…
Pratham
  • 13
  • 3
1
vote
1 answer

Java - How to calculate CRC16 of BitSet

I Have a Java BitSet where i have some data. The length of this BitSet is 545 bits. Problem: All current known implementations can only work with a byte array, but converting my BitSet to a byte array will change the data because i need to do some…
Phreag
  • 21
  • 3
1
vote
1 answer

How is this calculating CRC-A using polynomial - x^16 + x^12 + x^5 + 1

I came across this piece of code. But I am not sure how is CRC calculated here. I know the theoretical way of calculating CRC but I guess here it is using some kind of different logic, maybe. Please correct me. r_o[14:13] <= r_o[13:12]; r_o[12] …
newbie99
  • 53
  • 1
  • 6