CRC16 Checksum Generator
Generate 16-bit Cyclic Redundancy Check (CRC) checksums for error detection. Perfect for industrial protocols, data transmission, and storage verification. Multiple variants supported including CCITT, MODBUS, and IBM.
CRC16 checksum will appear here...Understanding CRC16 (Cyclic Redundancy Check)
CRC16 is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data [citation:2]. It works by treating the input data as a polynomial and performing polynomial division, producing a 16-bit remainder that serves as the checksum.
How CRC16 Works
The CRC16 algorithm performs polynomial division over the input data using a predetermined generator polynomial [citation:5]. The process involves:
- Initializing a 16-bit register with a start value
- Processing each byte through XOR operations and bit shifts
- Applying the polynomial when the most significant bit is set
- Optionally reflecting input/output bits and applying final XOR
Common CRC16 Variants [citation:2][citation:3][citation:5]
| Variant | Polynomial | Initial Value | Common Use |
|---|---|---|---|
| CRC-16/CCITT | 0x1021 | 0xFFFF | X.25, HDLC, XMODEM |
| CRC-16/MODBUS | 0x8005 | 0xFFFF | Modbus protocol |
| CRC-16/IBM | 0x8005 | 0x0000 | ARC, LHA |
| CRC-16/XMODEM | 0x1021 | 0x0000 | XMODEM protocol |
| CRC-16/USB | 0x8005 | 0xFFFF | USB packets |
Common Use Cases [citation:2][citation:10]
- Industrial Protocols: Modbus communication for PLCs and industrial automation
- USB: Error detection in USB packet transmission
- Telecommunications: X.25, HDLC, and other telecom protocols
- Storage Systems: Verifying data integrity in storage devices
- Embedded Systems: Serial communication and sensor data verification
Key Features
- 16-bit output (0-65535)
- 8 popular variants
- Text & Binary file support
- Modbus compatible
- Extremely fast computation
CRC16 Specifications
| Output Size | 16 bits (2 bytes) |
|---|---|
| Hex Length | 4 characters |
| Decimal Range | 0 to 65535 |
| Polynomial Length | 17 bits |
| Detection Capability | All single-bit, double-bit, odd-bit errors |
| Common Polynomials | 0x1021, 0x8005, 0x3D65 |
| Primary Use | Error detection |
| Security Suitability | Not for security |
Modbus Protocol Example [citation:3]
Modbus RTU Frame Structure
Modbus RTU uses CRC16 for error checking. A typical Modbus frame includes:
- Address: 1 byte (device address)
- Function Code: 1 byte (read/write command)
- Data: n bytes (register address, value, etc.)
- CRC16: 2 bytes (checksum of all preceding bytes)
Example Calculation
Request: 01 06 00 01 03 00 (set register 1 to value 0x0300)
CRC16/MODBUS: D8 FA (calculated with polynomial 0x8005, initial 0xFFFF, bit reflection)
Note: Modbus sends CRC bytes in little-endian order (least significant byte first)
CRC16 Hash Examples (by variant)
| Input | CRC-16/CCITT | CRC-16/MODBUS | CRC-16/XMODEM |
|---|---|---|---|
Hello, World! | FA4D | 56C2 | 5A23 |
The quick brown fox jumps over the lazy dog | 92F8 | 3F0A | 1B8C |
1234567890 | 31C3 | C3B3 | A2B1 |
Note: Different variants produce different results for the same input
JavaScript Implementation [citation:2][citation:5]
CRC-16/CCITT Implementation
function crc16CCITT(data) {
let crc = 0xFFFF;
const polynomial = 0x1021;
for (let i = 0; i < data.length; i++) {
crc ^= data.charCodeAt(i) << 8;
for (let j = 0; j < 8; j++) {
if (crc & 0x8000) {
crc = (crc << 1) ^ polynomial;
} else {
crc <<= 1;
}
crc &= 0xFFFF;
}
}
return crc.toString(16).toUpperCase();
}CRC-16/MODBUS Implementation
function crc16Modbus(data) {
let crc = 0xFFFF;
const polynomial = 0x8005;
for (let i = 0; i < data.length; i++) {
crc ^= data.charCodeAt(i);
for (let j = 0; j < 8; j++) {
if (crc & 0x0001) {
crc = (crc >> 1) ^ polynomial;
} else {
crc >>= 1;
}
}
}
return crc.toString(16).toUpperCase();
}Frequently Asked Questions About CRC16
- Modbus devices: Use CRC-16/MODBUS
- USB: Use CRC-16/USB
- XMODEM file transfer: Use CRC-16/XMODEM
- Telecom (X.25, HDLC): Use CRC-16/CCITT
- ARC/LHA archives: Use CRC-16/IBM
- 100% of all single-bit errors
- 100% of all double-bit errors
- 100% of all odd-numbered bit errors
- 100% of burst errors up to 16 bits
- 99.998% of longer burst errors
All CRC16 calculations are performed client-side in your browser. Your data never leaves your device. No information is stored or transmitted to any server.
Note: CRC16 is for error detection only, not cryptographic security. For secure hashing, use SHA-256 or SHA-512.