CRC Calculator
Calculate CRC checksums — CRC-8, CRC-16, CRC-32, and custom polynomials.
CRC計算ツールのしくみ
CRC計算ツールは、CRC-8、CRC-16、CRC-16/CCITT、CRC-32、Modbus CRC-16などの標準CRCアルゴリズムを使用して、テキストまたは16進数データの巡回冗長検査値を生成します。組み込みシステムのエンジニアはCRCを使用して、シリアル通信、フラッシュメモリ、ファイル転送、ネットワークプロトコルでのデータ整合性を検証し、単純なチェックサムでは見逃す1ビットと複数ビットのエラーをキャッチします。
CRCは入力データを大きなバイナリ多項式として扱い、モジュロ2演算(XOR演算、桁上げなし)を使用して生成多項式で割ります。この除算の余りがCRC値です。CRC-16の余りは16ビット幅で、CRC-32は32ビットの余りを生成します。受信側では同じ除算が実行されます — ゼロの余りはデータがエラーなく届いたことを確認し、ゼロ以外の余りは破損を示します。
CRC-8(多項式0x07)はI2Cエラーチェックに使用されます。CRC-16/IBM(0x8005)はModbus RTU、USB、産業用プロトコルで一般的です。CRC-16/CCITT(0x1021)はHDLC、X.25、SDカード通信に使われます。CRC-32(0x04C11DB7)はEthernetフレーム、ZIPファイル、PNG画像に使用されます。計算ツールはこれらすべての多項式をサポートし、それを必要とするプロトコルのビット反転(LSBファースト)を処理します。
Modbus RTUはすべてのフレームに16ビットCRCを付加します。Modbus CRC-16は初期値0xFFFFで始まり、多項式0x8005を反転(LSBファーストで0xA001)して使用し、最後に0x0000とXORします。計算ツールのModbusモードは、Modbusフレームへの直接挿入のための正しいバイト順(低バイトが先、次に高バイト)で正しい2つのCRCバイトを生成します。
CRC-32はすべての1ビットと2ビットのエラー、すべての奇数ビットエラー、32ビットまでのすべてのバーストエラー、そしてほとんどのそれ以上のバーストエラーを検出できます。ランダムエラーの検出確率は1 − 2⁻³² ≈ 99.9999998%です。安全性が重要な組み込みアプリケーションでは、これらの保証を理解することが重要です。CRCは通信エラー検出に適切ですが、暗号ハッシュではなく、セキュリティ目的には使用すべきではありません。
よくある質問
- What is a CRC?
- A Cyclic Redundancy Check (CRC) is an error-detecting code used to verify data integrity. A generator polynomial is applied to the data bytes via modulo-2 division, producing a fixed-length remainder (the CRC). Appending the CRC to a data frame lets the receiver recompute and compare — a mismatch means the data was corrupted in transit.
- Which CRC variant should I use?
- Match the variant required by your protocol. CRC-32 is used in Ethernet, ZIP, and PNG. CRC-16/MODBUS is the standard for Modbus RTU industrial communications. CRC-16/CCITT (and X-25) are used in HDLC, PPP, and SD cards. CRC-16/IBM appears in USB and legacy industrial protocols. CRC-8 is common in 1-Wire and SMBus. CRC-32C (Castagnoli) is used in iSCSI and SCTP.
- What is the Modbus CRC-16 formula?
- Modbus RTU uses CRC-16 with polynomial 0x8005, initial value 0xFFFF, reflected input and output (LSB-first), and XorOut of 0x0000. The two CRC bytes are appended in low-byte-first order. The calculator's CRC-16/MODBUS preset applies these parameters exactly. Enter your frame bytes in hex (space-separated) to get the two bytes to append.
- What is the difference between reflected and non-reflected CRC?
- Reflected (LSB-first) CRC processes each byte starting from the least significant bit — used in CRC-32, CRC-16/MODBUS, and most Ethernet variants. Non-reflected (MSB-first) processes from the most significant bit — used in CRC-16/CCITT-FALSE and CRC-32/BZIP2. The RefIn and RefOut parameters control this; the calculator shows both values for whichever preset is active.
- How do I verify a CRC checksum?
- To verify: take the received data bytes (without the appended CRC), run them through the same CRC algorithm, and compare your computed result to the received CRC. If they match, the data arrived intact. Alternatively, for some algorithms, appending the CRC bytes to the data and computing the CRC again produces a fixed constant (called the check value) — a non-zero result indicates corruption.
- What is CRC-32 used for in ZIP and PNG files?
- ZIP stores a CRC-32 in each file header to verify extraction integrity — if the decompressed bytes produce a different CRC-32, the archive is corrupt. PNG stores CRC-32 at the end of every chunk (IHDR, IDAT, etc.) to detect chunk-level corruption. Both use the standard CRC-32 polynomial 0x04C11DB7 with reflected bit order, matching the CRC-32 preset in this calculator.
- What is the difference between CRC and MD5 or SHA?
- CRC is designed for accidental error detection in communication and storage — it is fast, hardware-friendly, and suitable for detecting noise and single-bit errors, but it is not cryptographically secure (an attacker can intentionally craft a collision). MD5 and SHA are cryptographic hash functions designed to be collision-resistant and pre-image resistant for security use cases like digital signatures. For error detection in embedded systems or protocols, CRC is correct. For data authentication or password hashing, use SHA-256 or better.
- Can I calculate CRC for hexadecimal byte sequences?
- Yes — switch the input mode to HEX and enter space-separated hex byte pairs (e.g. 01 FF A3 B2). This is the correct mode when working with protocol frames, register maps, or binary data where you know the byte values but not a text representation. The text mode uses UTF-8 encoding; the hex mode treats each byte pair directly as a binary value.
関連ツール
- Resistor Color Code Calculator
Decode resistor color bands. Supports 4-band and 5-band.
- Ohm's Law Calculator
Calculate voltage, current, resistance, or power using Ohm's Law.
- Voltage Divider Calculator
Calculate output voltage for a resistor voltage divider.
- 555 Timer Calculator
Calculate frequency, duty cycle, and timing for 555 timer circuits.
- IEEE 754 Converter
Convert decimal numbers to IEEE 754 floating point representation.