Optional xxHash support and native SHA2-256 from browser Web Crypto API or Node.js crypto
#15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @pi0.
I created the
useHash()
function that supported the xxHash32 algorithm fromhash-wasm
or native SHA-256 (with fallback).Resolves #14, differences:
xxHash32
(5.(3) unpadded bytes, 8 padded, max value —/////w==
),instead of
xxHash64
(10.(6) unpadded bytes, 12 padded, max value —//////////8=
);SHA2-256
if thehash-wasm
package is not installed:crypto
variable (browser and Node.js);crypto
module (Node.js);createHash()
fromcrypto
module (Node.js);sha256base64()
.From my point of view, best solution it's to change the hashed string max length from 10 to 11 bytes and use the
xxHash64
algorithm instead.Added tests for #11 issue for xxHash32 and SHA-256 algorithms.
Example of usage
Best wishes,
Sergey.