Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sha256-uint8array

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sha256-uint8array

Fast SHA-256 digest hash based on Uint8Array, pure JavaScript.

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42K
decreased by-34.97%
Maintainers
1
Weekly downloads
 
Created
Source

sha256-uint8array

Node.js CI npm version

Fast SHA-256 digest hash based on Uint8Array, pure JavaScript.

SYNOPSIS

const createHash = require("sha256-uint8array").createHash;

const text = "";
const hex = createHash().update(text).digest("hex");
// => "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

const data = new Uint8Array(0);
const hash = createHash().update(data).digest();
// => <Uint8Array e3 b0 c4 42 98 fc 1c 14 9a fb f4 c8 99 6f b9 24 27 ae 41 e4 64 9b 93 4c a4 95 99 1b 78 52 b8 55>

The interface is a subset of Node.js's crypto module. See TypeScript declaration sha256-uint8array.d.ts for detail.

BENCHMARK

Node.js's native crypto module run faster than others on Node.js. sha256-uint8array runs well both on Node.js and browsers with its smaller footprint.

moduleversionnode.js V14Chrome 87Safari 14minifiedbackendnote
crypto-99ms 👍---OpenSSL👍 on node.js
sha256-uint8array0.8.0261ms474ms 👍270ms 👍3KB 👍Uint8Array👍 on browsers
crypto-js4.0.0835ms928ms957ms108KBUint8Arraycrypto-js/sha256.js
jssha3.2.0852ms937ms950ms10KBUint8Arrayjssha/dist/sha256.js
hash.js1.1.7654ms631ms1,641ms7KBArrayhash.js/lib/hash/sha/1.js
sha.js2.4.11351ms731ms3,617ms27KBBuffersha.js/sha256.js
create-hash1.2.0404ms788ms3,640ms97KBBuffercreate-hash/browser.js
jshashes1.0.81,532ms2,335ms1,128ms23KBArrayjshashes/hashes.js

The benchmark result above is tested on macOS 10.15.7 Intel Core i7 3.2GHz. You could run the benchmark as below.

git clone https://github.com/kawanet/sha256-uint8array.git
npm install
npm run build

# run the benchmark on Node.js
REPEAT=10000 ./node_modules/.bin/mocha test/99.benchmark.js

# run tests and the benchmark on browser
make -C browser test

BROWSER

<script src="https://cdn.jsdelivr.net/npm/sha256-uint8array/dist/sha256-uint8array.min.js"></script>
<script>
  const text = "";
  const hex = SHA256.createHash().update(text).digest("hex");
  // => "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

  const data = new Uint8Array(0);
  const hash = SHA256.createHash().update(data).digest();
  // => <Uint8Array e3 b0 c4 42 98 fc 1c 14 9a fb f4 c8 99 6f b9 24 27 ae 41 e4 64 9b 93 4c a4 95 99 1b 78 52 b8 55>
</script>

MIT LICENSE

Copyright (c) 2020-2021 Yusuke Kawasaki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 11 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc