I want to combine two precalculated crc32 into new one:
Example code in nodejs:
// i'm using crc32 lib: https://github.com/brianloveswords/buffer-crc32/blob/master/index.js
var crc32 = require('buffer-crc32');
var foo = new Buffer('foo');
var bar = new Buffer('bar');
var fooCrc32 = crc32(foo); // <Buffer 8c 73 65 21>
var barCrc32 = crc32(bar); // <Buffer 76 ff 8c aa>
// how to combine crc32 of foo and crc32 of bar to get crc32 of 'foobar'
var foobarCrc32 = some_function(fooCrc32, barCrc32); // <Buffer 9e f6 1f 95>
How to to this in nodejs? I know this is possible because of zlib crc32_combine function:
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2.
But I don't know how to implement it in nodejs. Is there any library in nodejs that do this or maybe some GIST? Can anyone provide that function in nodejs?
If someone else need that functionality I've made module for node: