当前位置: 首页 > news >正文

Fast CRC32

链接: Fast CRC32

Error Checking

Real life data tends to get corrupted because machines (and humans) are never as reliable as we wish for. One efficient way is make sure your data wasn't unintendedly modifiied is to generate some kind of hash. That hash shall be unique, compact and efficient:

  • unique: any kind of modification to the data shall generate a different hash
  • compact: as few bits or bytes as possible to keep the overhead low
  • efficient: use little computing resources, i.e. fast and low memory usage

Many protocols, like Ethernet and GZIP archives, append a so-called CRC hash to their data streams which has a few weaknesses regarding uniqueness (sometimes data modifications remain undetected) but is absolutely great when it comes to compactness (CRC32: 32 bits) and efficiency. You find a CRC32 right below every Download button on my blog, too.

There is one very useful property of CRC32: it can be implemented as a rolling algorithm. That means, if you already have some chunk of data and its CRC, then you can append new data and compute the updated CRC but using your original CRC as a seed and just scanning through the appended data.

I don't want to go into mathematical details of Cyclic Redundancy Checking because there are tons of information on the internet, e.g. Wikipedia and the Painless Guide To CRC Error Detection Algorithms. This article only discusses how to write a fast CRC32 algorithm in C/C++.

If you aren't too keen on technical details and just want to have the fastest implementation for not-too-small datasets, I strongly recommend using the crc32_fast function.

Note: The concepts behind the various CRC32 algorithm are not my original work - I only gathered them in one place.

http://www.lryc.cn/news/460573.html

相关文章:

  • 生成一个带有二维数据和对应标签的螺旋形数据集(非线性可分数据集)的代码解析
  • PHP unset() 函数的作用
  • 长篇故事可视化方法Story-Adapter:能够生成更高质量、更具细腻交互的故事图像,确保每一帧都能准确地传达故事情节。
  • C++基础面试题 | 什么是C++中的运算符重载?
  • 深入 IDEA 字节码世界:如何轻松查看 .class 文件?
  • NodeJS 利用代码生成工具编写GRPC
  • uni-app基础语法(一)
  • Linux:进程控制(三)——进程程序替换
  • LeetCode279:完全平方数
  • python爬虫--某动漫信息采集
  • 使用Rollup.js快速开始构建一个前端项目
  • 10.15学习
  • mongodb-7.0.14分片副本集超详细部署
  • C++运算出现整型溢出
  • LeetCode岛屿数量
  • Karmada核心概念
  • Rust 与生成式 AI:从语言选择到开发工具的演进
  • Python爬虫高效数据爬取方法
  • C语言之扫雷小游戏(完整代码版)
  • Spring WebFlux 响应式概述(1)
  • Unity游戏通用框架——事件的订阅和发布(观察者模式)
  • 将 Ubuntu 系统中的 **swap** 空间从 2GB 扩展到 16GB
  • 流程图 LogicFlow
  • Mac通过键盘选取内容
  • 如何通过OpenCV实现图像融合拼接?
  • Qt5.14.2 安装详细教程(图文版)
  • 深圳市步步精科技有限公司荣获发明专利,彰显技术研发实力
  • std::function的概念和使用方法
  • OpenAI的Swarm是一个实验性质的多智能体编排框架
  • 简易STL实现 | Map 的实现