Socket
Socket
Sign inDemoInstall

@aws-crypto/sha256-browser

Package Overview
Dependencies
10
Maintainers
8
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @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.


Version published
Weekly downloads
9.7M
decreased by-16.77%
Maintainers
8
Install size
632 kB
Created
Weekly downloads
 

Package description

What is @aws-crypto/sha256-browser?

The @aws-crypto/sha256-browser npm package is a JavaScript implementation of the SHA-256 cryptographic hash function specifically optimized for browser environments. It is part of the AWS SDK for JavaScript and is used to generate SHA-256 hashes of data, which is a common requirement for various security-related operations such as data integrity checks, digital signatures, and password hashing.

What are @aws-crypto/sha256-browser's main functionalities?

Generating SHA-256 hash

This feature allows you to generate a SHA-256 hash of the given data. The code sample demonstrates how to import the Sha256 class, create a new instance, update it with data, and then obtain the digest (the hash) as a promise.

import { Sha256 } from '@aws-crypto/sha256-browser';

async function hashData(data) {
  const hash = new Sha256();
  hash.update(data);
  return hash.digest();
}

const data = new Uint8Array([/* data bytes here */]);
hashData(data).then(digest => {
  console.log(digest);
});

Other packages similar to @aws-crypto/sha256-browser

Changelog

Source

5.2.0 (2023-10-16)

Features

  • support ESM artifacts in all packages (#752) (e930ffb)

Readme

Source

@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

FAQs

Last updated on 16 Oct 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc