1. @aws-crypto/sha256-browser
SHA256 wrapper for browsers that prefers `window.crypto.subtle` but will fall back to a pure JS implementation in @aws-crypto/sha256-js to provide a consistent interface for SHA256.
@aws-crypto/sha256-browser
Package: @aws-crypto/sha256-browser
Created by: aws
Last modified: Mon, 16 Oct 2023 19:44:49 GMT
Version: 5.2.0
License: Apache-2.0
Downloads: 48,738,166
Repository: https://github.com/aws/aws-sdk-js-crypto-helpers

Install

npm install @aws-crypto/sha256-browser
yarn add @aws-crypto/sha256-browser

@aws-crypto/sha256-browser

SHA256 wrapper for browsers that prefers window.crypto.subtle but will
fall back to a pure JS implementation in @aws-crypto/sha256-js
to provide a consistent interface for SHA256.

Usage

  • To hash "some data"
import {Sha256} from '@aws-crypto/sha256-browser'

const hash = new Sha256();
hash.update('some data');
const result = await hash.digest();

  • To hmac "some data" with "a key"
import {Sha256} from '@aws-crypto/sha256-browser'

const hash = new Sha256('a key');
hash.update('some data');
const result = await hash.digest();

Test

npm test

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code