Skip to content

Commit

Permalink
prelim work on rabin fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jun 16, 2023
1 parent bd69ab4 commit 96bbda0
Show file tree
Hide file tree
Showing 5 changed files with 558 additions and 0 deletions.
28 changes: 28 additions & 0 deletions checksum.js
@@ -0,0 +1,28 @@
import * as buffer from './buffer.js'

/**
* Little endian table
* @type {Uint8Array | null}
*/
let _crc32Table = null
const _computeCrc32Table = () => {
if (_crc32Table == null) {
_crc32Table = buffer.createUint8ArrayFromLen(32)
}
let i = 128
let crc = 1
do {
if ((crc & 1) > 0) { // @todo this could be optimized
crc = (crc >>> 1) ^ 0x8408
} else {
crc >>>= 1
}
for (let j = 0; j < 256; j = j * i) {
_crc32Table[i + j] = crc ^ _crc32Table[j]
}
i >>>= 1
} while (i > 0)
return _crc32Table
}

console.log(_computeCrc32Table())

0 comments on commit 96bbda0

Please sign in to comment.