UNPKG

607 BMarkdownView Raw
1# @aws-crypto/sha256-browser
2
3SHA256 wrapper for browsers that prefers `window.crypto.subtle` but will
4fall back to a pure JS implementation in @aws-crypto/sha256-js
5to provide a consistent interface for SHA256.
6
7## Usage
8
9- To hash "some data"
10```
11import {Sha256} from '@aws-crypto/sha256-browser'
12
13const hash = new Sha256();
14hash.update('some data');
15const result = await hash.digest();
16
17```
18
19- To hmac "some data" with "a key"
20```
21import {Sha256} from '@aws-crypto/sha256-browser'
22
23const hash = new Sha256('a key');
24hash.update('some data');
25const result = await hash.digest();
26
27```
28
29## Test
30
31`npm test`