{"id":41228,"date":"2023-09-27T21:30:34","date_gmt":"2023-09-27T13:30:34","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=41228"},"modified":"2023-09-27T21:30:34","modified_gmt":"2023-09-27T13:30:34","slug":"ccxzmx","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/41228.html","title":{"rendered":"CRC\u7a0b\u5e8f\u600e\u4e48\u5199\uff1f"},"content":{"rendered":"

  CRC\uff08\u5faa\u73af\u5197\u4f59\u6821\u9a8c\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6570\u636e\u6821\u9a8c\u7b97\u6cd5\uff0c\u5b83\u53ef\u4ee5\u68c0\u6d4b\u51fa\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u53d1\u751f\u7684\u9519\u8bef\u3002\u5b83\u7684\u6838\u5fc3\u539f\u7406\u662f\u5229\u7528\u4e00\u5b9a\u7684\u6a21\u5f0f\uff08\u4e5f\u53eb\u505a\u751f\u6210\u591a\u9879\u5f0f\uff09\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u591a\u9879\u5f0f\u8fd0\u7b97\uff0c\u5f97\u5230\u4e00\u4e2a\u6821\u9a8c\u7801\uff0c\u7528\u6765\u6821\u9a8c\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002CRC\u7a0b\u5e8f\u600e\u4e48\u5199\uff1f\u672c\u6587\u5c31\u4ecb\u7ecdCRC\u7a0b\u5e8f\u7684\u7f16\u5199\u65b9\u6cd5\u3002<\/p>\n

CRC\u7a0b\u5e8f\u7684\u6982\u5ff5<\/h2>\n

  CRC\u7a0b\u5e8f\u7684\u6838\u5fc3\u6982\u5ff5\u662f\u901a\u8fc7\u4f7f\u7528\u4e00\u4e2a\u591a\u9879\u5f0f\uff08\u4e5f\u53eb\u751f\u6210\u591a\u9879\u5f0f\uff09\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u591a\u9879\u5f0f\u8fd0\u7b97\uff0c\u5f97\u5230\u4e00\u4e2a\u6821\u9a8c\u7801\uff0c\u7528\u6765\u6821\u9a8c\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002<\/p>\n

  CRC\u7a0b\u5e8f\u7684\u7f16\u5199\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u4e00\u4e2a\u591a\u9879\u5f0f\uff0c\u7136\u540e\u6839\u636e\u591a\u9879\u5f0f\u7684\u5b9a\u4e49\uff0c\u8ba1\u7b97\u51fa\u5bf9\u5e94\u7684\u6821\u9a8c\u7801\u3002\u5177\u4f53\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

  1. \u9009\u62e9\u591a\u9879\u5f0f<\/h3>\n

  CRC\u7a0b\u5e8f\u7684\u7f16\u5199\uff0c\u9996\u5148\u8981\u9009\u62e9\u4e00\u4e2a\u591a\u9879\u5f0f\uff0c\u591a\u9879\u5f0f\u7684\u9009\u62e9\u53ef\u4ee5\u6839\u636e\u9700\u8981\uff0c\u9009\u62e9\u4e0d\u540c\u7684\u591a\u9879\u5f0f\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002<\/p>\n

  2. \u8ba1\u7b97\u6821\u9a8c\u7801<\/h3>\n

  \u6839\u636e\u6240\u9009\u62e9\u7684\u591a\u9879\u5f0f\uff0c\u8ba1\u7b97\u51fa\u5bf9\u5e94\u7684\u6821\u9a8c\u7801\uff0c\u8fd9\u4e00\u6b65\u9aa4\u901a\u5e38\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u7b97\u6cd5\uff0c\u4ee5\u8ba1\u7b97\u51fa\u5bf9\u5e94\u7684\u6821\u9a8c\u7801\u3002<\/p>\n

  3. \u5bf9\u6bd4\u6821\u9a8c\u7801<\/h3>\n

  \u6700\u540e\u4e00\u6b65\uff0c\u5c31\u662f\u5c06\u8ba1\u7b97\u51fa\u7684\u6821\u9a8c\u7801\uff0c\u4e0e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u6821\u9a8c\u7801\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u4e24\u8005\u76f8\u540c\uff0c\u5219\u8bf4\u660e\u6570\u636e\u6ca1\u6709\u53d1\u751f\u9519\u8bef\uff0c\u53cd\u4e4b\uff0c\u5219\u8bf4\u660e\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u53d1\u751f\u4e86\u9519\u8bef\u3002<\/p>\n

CRC\u7a0b\u5e8f\u7684\u5b9e\u73b0<\/h2>\n

  CRC\u7a0b\u5e8f\u7684\u7f16\u5199\uff0c\u4e00\u822c\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u6216\u8005C++\u8bed\u8a00\u6765\u5b9e\u73b0\uff0c\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

  1. \u5b9a\u4e49\u591a\u9879\u5f0f<\/h3>\n

  \u9996\u5148\uff0c\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u591a\u9879\u5f0f\uff0c\u591a\u9879\u5f0f\u7684\u5b9a\u4e49\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u6216\u8005C++\u8bed\u8a00\u4e2d\u7684\u6570\u7ec4\u6765\u5b9a\u4e49\uff0c\u4f8b\u5982\uff1a<\/p>\n

int crc_poly[8] = { 0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1A, 0x1C };<\/code><\/pre>\n

  2. \u8ba1\u7b97\u6821\u9a8c\u7801<\/h3>\n

  \u6839\u636e\u591a\u9879\u5f0f\u7684\u5b9a\u4e49\uff0c\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u6216\u8005C++\u8bed\u8a00\u7684\u5faa\u73af\u8bed\u53e5\u6765\u8ba1\u7b97\u51fa\u6821\u9a8c\u7801\uff0c\u4f8b\u5982\uff1a<\/p>\n

for (int i = 0; i < 8; i++) {

   crc ^= crc_poly[i];<\/p> }<\/code><\/pre>\n

  3. \u5bf9\u6bd4\u6821\u9a8c\u7801<\/h3>\n

  \u6700\u540e\uff0c\u5c31\u662f\u5c06\u8ba1\u7b97\u51fa\u7684\u6821\u9a8c\u7801\uff0c\u4e0e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u6821\u9a8c\u7801\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u4e24\u8005\u76f8\u540c\uff0c\u5219\u8bf4\u660e\u6570\u636e\u6ca1\u6709\u53d1\u751f\u9519\u8bef\uff0c\u53cd\u4e4b\uff0c\u5219\u8bf4\u660e\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u53d1\u751f\u4e86\u9519\u8bef\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  CRC\u7a0b\u5e8f\u7684\u7f16\u5199\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u4e00\u4e2a\u591a\u9879\u5f0f\uff0c\u7136\u540e\u6839\u636e\u591a\u9879\u5f0f\u7684\u5b9a\u4e49\uff0c\u8ba1\u7b97\u51fa\u5bf9\u5e94\u7684\u6821\u9a8c\u7801\uff0c\u6700\u540e\u5c06\u8ba1\u7b97\u51fa\u7684\u6821\u9a8c\u7801\uff0c\u4e0e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u6821\u9a8c\u7801\u8fdb\u884c\u6bd4\u8f83\uff0c\u4ee5\u786e\u5b9a\u6570\u636e\u662f\u5426\u53d1\u751f\u4e86\u9519\u8bef\u3002<\/strong>CRC\u7a0b\u5e8f\u7684\u7f16\u5199\uff0c\u53ef\u4ee5\u4f7f\u7528C\u8bed\u8a00\u6216\u8005C++\u8bed\u8a00\u6765\u5b9e\u73b0\uff0c\u6574\u4e2a\u8fc7\u7a0b\u7b80\u5355\u6613\u61c2\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

CRC\uff08\u5faa\u73af\u5197\u4f59\u6821\u9a8c\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6570\u636e\u6821\u9a8c\u7b97\u6cd5\uff0c\u5b83\u53ef\u4ee5\u68c0\u6d4b\u51fa\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u53d1\u751f\u7684\u9519\u8bef\u3002\u5b83\u7684\u6838\u5fc3\u539f\u7406\u662f\u5229\u7528\u4e00\u5b9a\u7684\u6a21\u5f0f\uff08\u4e5f\u53eb\u505a\u751f\u6210\u591a\u9879\u5f0f\uff09\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u591a\u9879\u5f0f\u8fd0\u7b97\uff0c\u5f97\u5230\u4e00\u4e2a\u6821<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[151],"class_list":["post-41228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-crc"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/41228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=41228"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/41228\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=41228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=41228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=41228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}