正 文:
飘易有个蓝牙项目使用了protobuf解包、打包,项目前端是js版本,里面需要用到一个crc32计算。
用法也很简单,下载它里面的crc32.js文件
或者直接使用国内的cdn:
具体的方法:CRC32.str("SheetJS") // -1647298270
CRC32.bstr("SheetJS") // -1647298270
CRC32.buf([ 83, 104, 101, 101, 116, 74, 83 ]) // -1647298270
但是,飘易接触到的这个项目,crc32的计算值只接受 Uint32 无符号整数;而这个类库的crc32却出现了负数。怎么办?检查源码:/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32 */
var CRC32;
(function (factory) {
/*jshint ignore:start */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typ