如何在Javascript中使用自定义多项式实现CRC16? [英] How do I implement a CRC16 with a custom polynomial in Javascript?

查看:166
本文介绍了如何在Javascript中使用自定义多项式实现CRC16?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Javascript中使用自定义多项式实现CRC16。

I need to implement a CRC16 with a custom polynomial in Javascript.

在搜索了多个NPM模块和这个SO问题(以及注释建议的所有链接)之后:

After searching several NPM modules and this SO question ( as well as all the links the comments suggest ):

  • Javascript CRC16 sample code or implementation
  • https://github.com/donvercety/node-crc16

我离目标还差得远。

我的问题是,即使我有代码,也无法理解如何重用给定的CRC16解决方案,因为我不知道在哪里可以找到多项式代码中的定义。有了所有的变化,对我来说这太神秘了。

My problem is that even though I have the code, I can't understand how to re-use a given CRC16 solution because I don't know where to find the polynomial definition in the code. With all the shifts and whatnot it's just too cryptic for me.

我怎么能拥有CRC16函数具有自定义多项式?

How can I have a CRC16 function with a custom polynomial ?

推荐答案

链接的示例包含一个来自CRC多项式的表 。给定多项式,您当然可以找到生成表的代码。您可以找到用于计算任何CRC的代码,以及生成CRC代码的代码,包括表格, CRC的定义(多项式,位排序,初始值,最终异或值)。

The example linked has a table derived from the CRC polynomial. You can certainly find code that generates the table, given the polynomial. You can find code that computes any CRC, and code that generates CRC code, including the table, given the definition of the CRC (polynomial, bit-ordering, initial value, final xor value).

这篇关于如何在Javascript中使用自定义多项式实现CRC16?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆