Skip to content

Commit

Permalink
fix(docs): sha256 packages, clarify hmac support (#455)
Browse files Browse the repository at this point in the history
* sha256 packages: clarify hmac support

* fix(docs): sha256 packages, clarify hmac support

Co-authored-by: Lorentzen <crlorent@amazon.com>
Co-authored-by: Andrew Jewell <107044381+ajewellamz@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 2, 2022
1 parent c9cda20 commit 1be5043
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/sha256-browser/README.md
Expand Up @@ -6,6 +6,7 @@ to provide a consistent interface for SHA256.

## Usage

- To hash "some data"
```
import {Sha256} from '@aws-crypto/sha256-browser'
Expand All @@ -15,6 +16,16 @@ 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`
11 changes: 11 additions & 0 deletions packages/sha256-js/README.md
Expand Up @@ -4,6 +4,7 @@ A pure JS implementation SHA256.

## Usage

- To hash "some data"
```
import {Sha256} from '@aws-crypto/sha256-js';
Expand All @@ -13,6 +14,16 @@ const result = await hash.digest();
```

- To hmac "some data" with "a key"
```
import {Sha256} from '@aws-crypto/sha256-js';
const hash = new Sha256('a key');
hash.update('some data');
const result = await hash.digest();
```

## Test

`npm test`
2 changes: 1 addition & 1 deletion packages/sha256-js/test/jsSha256.test.ts
Expand Up @@ -82,7 +82,7 @@ describe("Sha256", () => {

idx = 0;
for (const [key, data, result] of hmacTestVectors) {
it("should match known hash calculations: " + idx++, async () => {
it("should match known hmac calculations: " + idx++, async () => {
const hash = new Sha256(key);
hash.update(data);
expect(await hash.digest()).to.deep.equal(result);
Expand Down
11 changes: 11 additions & 0 deletions packages/sha256-universal/README.md
Expand Up @@ -4,6 +4,7 @@ A consistent interface for SHA256 across browsers and NodeJs

## Usage

- To hash "some data"
```
import {Sha256} from '@aws-crypto/sha256-universal'
Expand All @@ -13,6 +14,16 @@ const result = await hash.digest();
```

- To hmac "some data" with "a key"
```
import {Sha256} from '@aws-crypto/sha256-universal'
const hash = new Sha256('a key');
hash.update('some data');
const result = await hash.digest();
```

## Test

`npm test`

0 comments on commit 1be5043

Please sign in to comment.