Stax
Tools

CRC Calculator

Calculate CRC checksums — CRC-8, CRC-16, CRC-32, and custom polynomials.

Width: 16-bitPoly: 0x8005Init: 0xFFFFRefIn: trueRefOut: trueXorOut: 0x0

วิธีการทำงานของเครื่องคำนวณ CRC

เครื่องคำนวณ CRC สร้างค่า cyclic redundancy check สำหรับข้อมูลข้อความหรือเลขฐานสิบหกโดยใช้อัลกอริทึม CRC มาตรฐาน รวมถึง CRC-8, CRC-16, CRC-16/CCITT, CRC-32 และ Modbus CRC-16 วิศวกรระบบ embedded ใช้ CRC เพื่อตรวจสอบความสมบูรณ์ของข้อมูลในการสื่อสาร serial, flash memory, การถ่ายโอนไฟล์ และโปรโตคอลเครือข่าย เพื่อตรวจจับข้อผิดพลาดบิตเดียวและหลายบิตที่ checksum แบบง่ายพลาด

CRC ถือข้อมูล input เป็น binary polynomial ขนาดใหญ่และหารด้วย generator polynomial โดยใช้การคำนวณแบบ modulo-2 (XOR ไม่มีการทดเลข) เศษจากการหารนี้คือค่า CRC CRC-16 มีเศษกว้าง 16 บิต CRC-32 ผลิตเศษ 32 บิต ที่ receiver จะทำการหารเดิมซ้ำ เศษเป็นศูนย์ยืนยันว่าข้อมูลมาถึงโดยไม่มีข้อผิดพลาด เศษที่ไม่ใช่ศูนย์บ่งบอกการเสียหาย

CRC-8 (polynomial 0x07) ใช้ในการตรวจสอบข้อผิดพลาด I2C CRC-16/IBM (0x8005) พบในโปรโตคอล Modbus RTU, USB และอุตสาหกรรม CRC-16/CCITT (0x1021) ปรากฏใน HDLC, X.25 และการสื่อสาร SD card CRC-32 (0x04C11DB7) ใช้ใน Ethernet frame, ไฟล์ ZIP และรูปภาพ PNG เครื่องคำนวณรองรับ polynomial เหล่านี้ทั้งหมดและจัดการ bit reflection (LSB-first) สำหรับโปรโตคอลที่ต้องการ

Modbus RTU ใช้ CRC 16 บิตต่อท้ายทุก frame CRC-16 ของ Modbus เริ่มต้นด้วยค่าเริ่มต้น 0xFFFF ใช้ polynomial 0x8005 แบบ reflected (0xA001 ในรูปแบบ LSB-first) และ XOR ด้วย 0x0000 ที่ท้าย โหมด Modbus ของเครื่องคำนวณสร้างสอง CRC byte ที่ถูกต้องในลำดับ byte ที่ถูกต้อง (byte ต่ำก่อน แล้วตามด้วย byte สูง) สำหรับการแทรกโดยตรงใน Modbus frame

CRC-32 สามารถตรวจจับข้อผิดพลาดบิตเดียวและสองบิตทั้งหมด ข้อผิดพลาดบิตจำนวนคี่ทั้งหมด ข้อผิดพลาด burst ทั้งหมดที่ไม่เกิน 32 บิต และข้อผิดพลาด burst ที่ยาวกว่าส่วนใหญ่ ความน่าจะเป็นในการตรวจจับข้อผิดพลาดสุ่มคือ 1 − 2⁻³² ≈ 99.9999998% สำหรับแอปพลิเคชัน embedded ที่ต้องการความปลอดภัยสูง การเข้าใจการรับประกันเหล่านี้มีความสำคัญ CRC เหมาะสำหรับการตรวจจับข้อผิดพลาดการสื่อสาร แต่ไม่ใช่ hash เข้ารหัสและไม่ควรใช้เพื่อวัตถุประสงค์ด้านความปลอดภัย

คำถามที่พบบ่อย

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.

เครื่องมือที่เกี่ยวข้อง