New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chainsafe/as-sha256

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chainsafe/as-sha256

An AssemblyScript implementation of SHA256

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
93K
increased by3.45%
Maintainers
3
Weekly downloads
 
Created
Source

as-sha256

Assembly Script implementation of SHA256.

This repository contains two npm distributions; a pure AssemblyScript version, and a Typescript wrapper for the WASM build.

Benchmarks

Sha256-Rust#hash x 328,611 ops/sec ±5.99% (75 runs sampled)
Sha256-Js#hash x 340,641 ops/sec ±4.64% (77 runs sampled)
Sha256-Asm#hash x 5,217 ops/sec ±8.83% (74 runs sampled)
Sha256-BCrypto#hash x 411,191 ops/sec ±9.87% (59 runs sampled)
AS-Sha256#hash x 537,124 ops/sec ±8.91% (76 runs sampled)
Fastest is AS-Sha256#hash

AssemblyScript

yarn add @chainsafe/as-sha256

TypeScript Wrapper

yarn add @chainsafe/sha256

Usage

import sha256 from "@chainsafe/sha256";

const message = Buffer.from("Hello world");

const hash = sha256(message);

We also expose the lower level WASM exports for those that may wish to use it. It can be accessed as follows:

import sha256, {wasm} from "@chainsafe/sha256"

const buffer = Buffer.from("Hello world");
const array = wasm.__retain(wasm.__allocArray(wasm.UINT8ARRAY_ID, buffer));
const message = wasm.sha256(array)

// To prevent memory leaks
wasm.__release(array);
wasm.__release(message);

console.log(toHexString(wasm.__getUint8Array(message)));

License

LGPL-V3

FAQs

Package last updated on 06 Sep 2019

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