2 回复
crc32计算,可以参考下文档:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-zlib-V5#crc3212
import { zlib, BusinessError } from '[@kit](/user/kit).BasicServicesKit';
let str = 'hello world!';
let arrayBufferIn = new ArrayBuffer(12);
let data = new Uint8Array(arrayBufferIn);
for (let i = 0, j = str.length; i < j; i++) {
data[i] = str.charCodeAt(i);
}
let checksum = zlib.createChecksumSync()
checksum.crc32(0, arrayBufferIn).then((data) => {
console.info('crc32 success', data);
}).catch((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`);
})