Skip to content

Commit 1be5043

Browse files
crlorentzenLorentzenajewellamz
authored
fix(docs): sha256 packages, clarify hmac support (#455)
* sha256 packages: clarify hmac support * fix(docs): sha256 packages, clarify hmac support Co-authored-by: Lorentzen <[email protected]> Co-authored-by: Andrew Jewell <[email protected]>
1 parent c9cda20 commit 1be5043

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

packages/sha256-browser/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ to provide a consistent interface for SHA256.
66

77
## Usage
88

9+
- To hash "some data"
910
```
1011
import {Sha256} from '@aws-crypto/sha256-browser'
1112
@@ -15,6 +16,16 @@ const result = await hash.digest();
1516
1617
```
1718

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+
1829
## Test
1930

2031
`npm test`

packages/sha256-js/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ A pure JS implementation SHA256.
44

55
## Usage
66

7+
- To hash "some data"
78
```
89
import {Sha256} from '@aws-crypto/sha256-js';
910
@@ -13,6 +14,16 @@ const result = await hash.digest();
1314
1415
```
1516

17+
- To hmac "some data" with "a key"
18+
```
19+
import {Sha256} from '@aws-crypto/sha256-js';
20+
21+
const hash = new Sha256('a key');
22+
hash.update('some data');
23+
const result = await hash.digest();
24+
25+
```
26+
1627
## Test
1728

1829
`npm test`

packages/sha256-js/test/jsSha256.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe("Sha256", () => {
8282

8383
idx = 0;
8484
for (const [key, data, result] of hmacTestVectors) {
85-
it("should match known hash calculations: " + idx++, async () => {
85+
it("should match known hmac calculations: " + idx++, async () => {
8686
const hash = new Sha256(key);
8787
hash.update(data);
8888
expect(await hash.digest()).to.deep.equal(result);

packages/sha256-universal/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ A consistent interface for SHA256 across browsers and NodeJs
44

55
## Usage
66

7+
- To hash "some data"
78
```
89
import {Sha256} from '@aws-crypto/sha256-universal'
910
@@ -13,6 +14,16 @@ const result = await hash.digest();
1314
1415
```
1516

17+
- To hmac "some data" with "a key"
18+
```
19+
import {Sha256} from '@aws-crypto/sha256-universal'
20+
21+
const hash = new Sha256('a key');
22+
hash.update('some data');
23+
const result = await hash.digest();
24+
25+
```
26+
1627
## Test
1728

1829
`npm test`

0 commit comments

Comments
 (0)