sync-multihash-sha2
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

sync-multihash-sha2

Library provides alternative implementation of sha256 and sha512 hashing algorithms for those rare cases where implementation provided by multiformats may be prohibitively slow.

ℹ️ In vast majority of use cases multiformats is better choice. In rare instances where multiformats does not meet your requirements you could use this library, but please make sure to consider the offered tradeoffs.

Tradeoffs

tl;dr: This implementation has sync API and is faster in browsers, but more dependencies implies more bytes over the wire and greater risk of supply chain attacks.

💚 Faster & Sync

Library provides SyncMultihashHasher implementation which provides sync API in browser and node environments. This is accomplished by leveraging node:crypto in node and in @noble/hashes in browsers.

  • It can can be used in synchronous code paths
  • It significantly faster in browsers

💔 More dependencies

Since this library does not leverage web crypto APIs there is more code to be send over the wire. More dependencies also increase risk of supply chain attacks.

💔 Less future proof

Web crypto APIs deliberately provide async APIs, which this library provides sync API. Furthermore, native implementation appears significantly slower, possibly because browsers rate-limit API calls.

Difference in choices may prove problematic in longer.

Package Sidebar

Install

npm i sync-multihash-sha2

Weekly Downloads

2,375

Version

1.0.0

License

(Apache-2.0 AND MIT)

Unpacked Size

10.2 kB

Total Files

23

Last publish

Collaborators

  • it-dag-house