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