Calculate CRC32 from digit - how? #11
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/js-crc32#11
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi!
How I can calculate CRC32 from 32 bit hex digit like 0x200031E0 (CRC should be 0x0AAFD11A) or from 32 bit dec?
CRC32.buf
can take an array of bytes andCRC32.bstr
can take a binary string. Both return a signed 32-bit integer that you can convert to hex through unsigned conversion>>>0
andtoString(16)
.To convert the 32-bit number to bytes you can either unwind the bytes manually or use a Uint32Array:
The result is determined to be
0xe9fc314b
. How did you get that CRC result0x0AAFD11A
?Thank you, I did something similar you provided, but it would be great to have additional function like CRC32.int or CRC32.hex to calculate CRC without extra code.
You are right, the result should be
0xe9fc314b
it was my mistake.C'mon, splitting number into 4 bytes isn't worth any library support, and calculating 32-bit crc from 32-bit number does not seem to be very common use case.