本文介绍了Javascript CRC16示例代码或实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以共享链接或示例代码来实现javascript中字符串的校验和吗?
提前谢谢

can anybody share a link or sample code to implement checksum for string in javascript?Thanks a lot in advance

推荐答案

您想要什么?



您需要更具体些。

What do you want?

You need to be more specific.

有大量的CRC16算法,每种算法都有自己的多项式,并且有特定的用途。有些CRC16算法非常适合创建散列(例如,对于Redis而言),而其他算法则更适合于有线通信。

There is a huge plethora of CRC16 algorithms, each one with its own polynomial and for a specific use. Some CRC16 algorithms are really good to create hashes ( for Redis, for example ) while others are better for wire communication.



  • https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Polynomial_representations_of_cyclic_redundancy_checks

如果这是您要走的路,那么GitHub和NPM可以为您提供许多实现。

If this is the road you want to go with, then GitHub and NPM have many implementations that could work for you.

他们的文档通常非常可怕或不存在,不能保证它们会像广告中所宣传的那样工作,但是如果有任何更改,您可以随时尝试一下,并且如果您发现错误,可以随时在其问题页面中报告。

Their documentation is usually downright horrible or non-existent and there is no guarantee they will work as advertised, but if anything goes, you can always give them a try, and if you find a bug you can always report it in their issues page.

这是我发现的快速实现,应该是您所需要的:

Here is a quick implementation I found, should be what you need:



  • https://github.com/donvercety/node-crc16/blob/master/crc16.js

这篇关于Javascript CRC16示例代码或实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 10:10