问题
can anybody share a link or sample code to implement checksum for string in javascript? Thanks a lot in advance
回答1:
What do you want?
You need to be more specific.
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
I just want anything, I really don't care what
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
来源:https://stackoverflow.com/questions/45795958/javascript-crc16-sample-code-or-implementation