CRC Calculator

CRC8 Calculator

Calculate an 8-bit CRC for text or hex bytes. The table under the calculator shows all 20 CRC-8 variants for your input, so you can match the one your sensor, bus or protocol uses. CRC8 計算(日本語)

9 bytes
Parameters

ResultCRC-8

0xF4
Decimal
244
Binary
11110100
Bytes, big-endian
F4
Bytes, little-endian
F4

Check value for "123456789": 0xF4

Source code for this CRC

Generated for the parameters above. Bit-by-bit and table-free, so it is easy to port to a microcontroller.

#include <stddef.h>
#include <stdint.h>

uint8_t crc_8(const uint8_t *data, size_t len)
{
    uint8_t crc = 0x00;
    while (len--) {
        crc ^= (uint8_t)*data++;
        for (int i = 0; i < 8; i++)
            crc = (crc & 0x80) ? (crc << 1) ^ 0x07 : crc << 1;
    }
    return crc;
}

All CRC algorithms for this input

Click a row to load its parameters into the calculator.

AlgorithmResultPolyInitRefInRefOutXorOutCheckUsed in
0xF40x070x00falsefalse0x000xF4SMBus PEC, I2C sensors
0xA10x310x00truetrue0x000xA1Dallas/Maxim 1-Wire (DS18B20)
0xD00x070xFFtruetrue0x000xD0Robust Header Compression
0xA10x070x00falsefalse0x550xA1ATM HEC (ITU-T I.432.1)
0x4B0x1D0xFFfalsefalse0xFF0x4BAutomotive SAE J1850, AUTOSAR E2E
0xDF0x2F0xFFfalsefalse0xFF0xDFAUTOSAR E2E profiles
0xDA0x9B0xFFfalsefalse0x000xDACDMA2000 mobile
0x150x390x00truetrue0x000x15Data Radio Channel
0xBC0xD50x00falsefalse0x000xBCDVB-S2 baseband header
0x970x1D0xFFtruetrue0x000x97AES3 / EBU digital audio
0x7E0x1D0xFDfalsefalse0x000x7EPhilips I-CODE RFID
0x250x9B0x00truetrue0x000x25WCDMA mobile
0x260xA70x00truetrue0x000x26Bluetooth HEC
0xEA0x9B0x00falsefalse0x000xEALTE (3GPP TS 36.212)
0xF70x310xFFfalsefalse0x000xF7HD Radio, Sensirion SHT sensors
0x3E0x2F0x00falsefalse0x000x3EopenSAFETY
0x370x1D0x00falsefalse0x000x37GSM
0x940x490x00falsefalse0xFF0x94GSM
0xB40x1D0xFFfalsefalse0x000xB4HITAG RFID
0x990x1D0xC7falsefalse0x000x99MIFARE application directory

Common CRC8 variants

An 8-bit CRC protects short messages: a sensor reading, a command byte, a packet header. Because every vendor picked its own parameters, "CRC8" covers a family of incompatible algorithms. The check value is the CRC of the ASCII string 123456789.

VariantPolyInitReflectedXorOutCheckUsed in
CRC-8 (SMBus, ATM)0700no00F4SMBus PEC, I²C sensors, MLX90614
CRC-8/MAXIM3100yes00A11-Wire: DS18B20, iButton
CRC-8/NRSC-531FFno00F7Sensirion SHT3x, SCD4x, SGP
CRC-8/SAE-J18501DFFnoFF4BOBD, AUTOSAR E2E profile 1
CRC-8/AUTOSAR2FFFnoFFDFAUTOSAR E2E profile 2
CRC-8/ROHC07FFyes00D0Robust Header Compression
CRC-8/ITU0700no55A1ATM header error control
CRC-8/DVB-S2D500no00BCDVB-S2, CRSF radio link
CRC-8/BLUETOOTHA700yes0026Bluetooth header check

CRC8 in C

The plain CRC-8 with polynomial 0x07. For another non-reflected variant, change the polynomial, the starting value and the final XOR.

uint8_t crc8(const uint8_t *data, size_t len)
{
    uint8_t crc = 0x00;
    while (len--) {
        crc ^= *data++;
        for (int i = 0; i < 8; i++)
            crc = (crc & 0x80) ? (crc << 1) ^ 0x07 : crc << 1;
    }
    return crc;
}

Reflected variants such as CRC-8/MAXIM shift the other way and use the bit-reversed polynomial (0x8C for 0x31):

uint8_t crc8_maxim(const uint8_t *data, size_t len)
{
    uint8_t crc = 0x00;
    while (len--) {
        crc ^= *data++;
        for (int i = 0; i < 8; i++)
            crc = (crc & 1) ? (crc >> 1) ^ 0x8C : crc >> 1;
    }
    return crc;
}

The calculator above generates the matching C, Python and JavaScript for whichever variant is selected.

Test vectors

InputVariantCRC
BE EF (hex)CRC-8/NRSC-5 (Sensirion)92
helloCRC-892
helloCRC-8/MAXIM13
helloCRC-8/SAE-J1850A9

For longer frames use a wider check: the CRC16 calculator covers CCITT, MODBUS and XMODEM, the CRC32 calculator covers CRC-32 and CRC-32C, and the CRC64 calculator covers the 64-bit variants. If your protocol uses a plain sum or XOR instead of a CRC, try the checksum calculator.

Frequently asked questions

Which CRC8 polynomial is the standard one?

There is no single standard. The plain "CRC-8" uses polynomial 0x07 with initial value 0 and no reflection; it is the SMBus packet error code and is also called CRC-8/ATM or CRC-8/CCITT. Dallas/Maxim 1-Wire devices use 0x31 reflected, and automotive systems use 0x1D (SAE J1850) or 0x2F (AUTOSAR). Check your datasheet for the polynomial and the initial value.

What is the CRC8 of "123456789"?

It depends on the variant: 0xF4 for plain CRC-8, 0xA1 for CRC-8/MAXIM, 0x4B for CRC-8/SAE-J1850, 0xDF for CRC-8/AUTOSAR and 0xD0 for CRC-8/ROHC. These check values are the fastest way to confirm which variant a piece of code implements.

How do I calculate the CRC for a Sensirion SHT3x or SCD4x sensor?

Sensirion sensors use polynomial 0x31, initial value 0xFF, no reflection and no final XOR — listed here as CRC-8/NRSC-5. The datasheet test vector is the two bytes BE EF, which give 0x92. Each 16-bit word read from the sensor is followed by its own CRC byte.

What is the difference between polynomial 0x31 and 0x8C?

They are the same polynomial written in opposite bit orders: 0x8C is 0x31 reflected. Code that shifts right, as 1-Wire implementations do, stores it as 0x8C. Likewise 0xE0 is the reflected form of 0x07.

How reliable is an 8-bit CRC?

It detects every single-bit error and every burst up to 8 bits long, and lets about 1 in 256 of other corruptions through. That is fine for a few bytes on a short bus, which is where CRC-8 is used. For longer messages use CRC-16 or CRC-32.