can anybody share a link or sample code to implement checksum for string in javascript? Thanks a lot in advance
Asked
Active
Viewed 7,630 times
3
-
Have you at least tried searching in Google? – Hauleth Aug 21 '17 at 11:35
-
see this https://stackoverflow.com/questions/811195/fast-open-source-checksum-for-small-strings – Fatehi_Alqadasi Aug 21 '17 at 11:39
-
@ŁukaszNiemier i tried to google it but correct implementation not found. The checksum shall be calculated according to [ISO/IEC 13239] using the polynomial '1021' (hex) and initial value 'FFFF' (hex). – user2060221 Aug 21 '17 at 12:01
-
@Fatehi_Alqadasi thanks a lot for quick response..The checksum shall be calculated according to [ISO/IEC 13239] using the polynomial '1021' (hex) and initial value 'FFFF' (hex). Please suggest how to validate it. – user2060221 Aug 21 '17 at 12:04
-
this can help you https://stackoverflow.com/questions/18594963/crc16-iso-13239-implementation – Fatehi_Alqadasi Aug 21 '17 at 12:11
-
@Fatehi_Alqadasi i am looking for a solution in javascript not in C# – user2060221 Aug 21 '17 at 12:27
-
@ŁukaszNiemier do you have any suggestion for it ? – user2060221 Aug 21 '17 at 13:04
-
That's not a checksum. It's a CRC. The link in the answer below, https://github.com/donvercety/node-crc16/blob/master/crc16.js , is for code that computes the ISO/IEC 13239 CRC. – Mark Adler Apr 26 '18 at 05:52
1 Answers
0
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.
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:

Flame_Phoenix
- 16,489
- 37
- 131
- 266