Menu
  • HOME
  • TAGS

Generic CRC (8/16/32/64) combine implementation

c#,checksum,crc,crc16

The result 0x29b1 is for the "false" CCITT CRC-16. That CRC uses the polynomial unreflected, so you would use 0x1021 instead. See this list of CRC definitions. You also need to change the initialization of the zero operator, and account for the initialization of the CRC. Below is code (in...

Calculating CRC initial value instead of appending the CRC to payload

reverse,patch,crc,crc32,crc16

I've now programmed a solution for the above mentioned problem which was easier than I initially thought it would be. I found several articles about how one can forge a CRC. That means how to patch data that way that the calculated CRC value will have a predefined value. Using...

I got 0x1E error (INTEGRITY_ERROR) while change DESFire master key.What are my mistakes?And How can I resolve?

java,apdu,crc16,contactless-smartcard

DESFire cards uses a little different CRC16 from yours. Your initial value for CRC16 is 0xFFFF, but DESFire expects 0x6363. This may cause your troubles with the integrity error. I see no DEC/CBC encryption using decryption of your newPICCKey_deciphered array. You really have to use DECRYPTION MODE instead of...

Unknown CRC Calculation

reverse-engineering,checksum,crc,crc16

Here you go, in C: #include <stddef.h> unsigned crc16old(unsigned crc, unsigned char *buf, size_t len) { int k; if (buf == NULL) return 0xffff; while (len--) { crc ^= *buf++; for (k = 0; k < 8; k++) crc = crc & 1 ? (crc >> 1) ^ 0x8408 :...

CRC-16 (IBM) Reverse Lookup in C++

c++,checksum,crc,crc16

This code: #include <stdio.h> #define POLY 0xa001 unsigned crc16(unsigned crc, unsigned char *buf, size_t len) { while (len--) { crc ^= *buf++; crc = crc & 1 ? (crc >> 1) ^ POLY : crc >> 1; crc = crc & 1 ? (crc >> 1) ^ POLY : crc...

Why using Generator polynomial like this x^8 +x^2 +x+1 for CRC-8?

crc,crc32,crc16,error-detection,crc64

The polynomial chosen determines the error detection capability of the CRC. This capability is measured in Hamming Distance, which is the minimum number of bit errors that can be introduced in the message while leaving the CRC unchanged. This would be a false positive, where the CRC says the message...

Undefined reference to crcsum(unsigned char const*, unsigned long, unsigned short)

c,parameters,arduino,undefined-reference,crc16

Did you add crc.c into your arduino project? Either wrap your include of crc.h with extern "C" or rename the crc.c into crc.ino: extern "C" { #include "crc.h" } void setup() { crcsum((const unsigned char*)"0123456789", 50000, 4); } ...

Attempting to understand different CRC implementations

crc,crc32,crc16

This tutorial (also here, here, and here for those who will complain about link rot), in particular "10. A Slightly Mangled Table-Driven Implementation", explains well the optimization to avoid feeding an extra 32 zero bits at the end. The bottom line is that you feed the bits into the end...

Delphi to Java porting issue

java,android,delphi,modbus,crc16

The most obvious difference is here: for(flag=0;flag<7;flag++) This loops runs one fewer times than the Delphi version. You mean: for(flag=0;flag<8;flag++) On top of that, the Java code was needlessly complex. It can be greatly simplified. This program gives the same output as the Delphi code: import java.util.*; public class test...

How to detect errors in CRC-protected data?

data,crc,crc16,transmission

The appending the CRC thing only works for "pure" CRCs without pre and post-conditioning. Most real world CRCs however have pre and post-conditioning, mainly so that the CRC of strings of zeros are not zero. The way to check a CRC is the same as any other check value. You...

How to calculate CRC16 CCITT in PHP HEX?

php,hex,crc,crc16

I was able to produce the same checksum with implementation like below: define('CRC16POLYN', 0x1021); function CRC16Normal($buffer) { $result = 0xFFFF; if (($length = strlen($buffer)) > 0) { for ($offset = 0; $offset < $length; $offset++) { $result ^= (ord($buffer[$offset]) << 8); for ($bitwise = 0; $bitwise < 8; $bitwise++) {...

JAVA CRC16 function returns a 3 characters response instead of 4

java,crc,crc16

You're receiving ArrayIndexOutOfBoundException probably, so I think the hex value might have zero in its most significant nibble. Try to find out those values(x) and check whether (x >>> 12) == 0 or (x & 0xf000) == 0. If this returns true, you can pad your string with necessary number...

Java equivalent for C CRC16

java,c,crc16

Your translated the c code function call crc16 (const void *data, unsigned data_size) wrong. public static int getCode (String[] data) should be public static int getCode (String data) Moreover you can also see in the Wialon pdf that you need a getCode (String) and not a getCode(String[]). Converting the received...

CRC16 code from Java to PHP [duplicate]

java,php,crc16

Replace crc >>> 8 with (crc >> 8) & 0xff.