sha.js icon indicating copy to clipboard operation
sha.js copied to clipboard

support multi-byte wide typed arrays

Open ChALkeR opened this issue 1 year ago • 3 comments

Same as: https://github.com/browserify/hash-base/pull/19, https://github.com/browserify/cipher-base/pull/23, but retains support for Array and Array-like objects, since this module isn't closely mimicking the Node.js API

For array-likes, coherence rechecks are added to ensure invalid results are not returned

On everything Node.js createHash works, this now should be compatible + additionally keeps array-like support

ChALkeR avatar Dec 01 '24 03:12 ChALkeR

Looks like node < 8 doesn't support passing a typed array directly into .update

ljharb avatar Dec 01 '24 16:12 ljharb

@ljharb yes, but newer versions do + this impl works regardless when proper new Uint8Array and ArrayBuffer.isView are supported by the runtime, for compat with newer versions. It still matches old Node.js on everything with what old Node.js works.

ChALkeR avatar Dec 02 '24 01:12 ChALkeR

ah ok cool. then we just need an easy way to feature-detect whether update takes a typed array, for the tests :-)

ljharb avatar Dec 02 '24 05:12 ljharb