@chainsafe/as-sha256

An AssemblyScript implementation of SHA256


Keywords
assemblyscript, sha256, typescript, wasm
License
Apache-2.0
Install
npm install @chainsafe/as-sha256@0.4.1

Documentation

This package is now maintained at https://github.com/ChainSafe/ssz/tree/master/packages/as-sha256

as-sha256

ES Version Node Version

AssemblyScript implementation of SHA256.

Usage

yarn add @chainsafe/as-sha256

import SHA256 from "@chainsafe/as-sha256";

let hash: Uint8Array;

// create a new sha256 context
const sha256 = new SHA256();
// with init(), update(data), and final()
hash = sha256.init().update(Buffer.from("Hello world")).final();

// or use a one-pass interface
hash = SHA256.digest(Buffer.from("Hello world"));

// or use a faster one-pass interface for hashing (only) 64 bytes
hash = SHA256.digest64(Buffer.from("abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh"));

License

Apache 2.0