File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ to provide a consistent interface for SHA256.
6
6
7
7
## Usage
8
8
9
+ - To hash "some data"
9
10
```
10
11
import {Sha256} from '@aws-crypto/sha256-browser'
11
12
@@ -15,6 +16,16 @@ const result = await hash.digest();
15
16
16
17
```
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
+
18
29
## Test
19
30
20
31
` npm test `
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ A pure JS implementation SHA256.
4
4
5
5
## Usage
6
6
7
+ - To hash "some data"
7
8
```
8
9
import {Sha256} from '@aws-crypto/sha256-js';
9
10
@@ -13,6 +14,16 @@ const result = await hash.digest();
13
14
14
15
```
15
16
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
+
16
27
## Test
17
28
18
29
` npm test `
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ describe("Sha256", () => {
82
82
83
83
idx = 0 ;
84
84
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 ( ) => {
86
86
const hash = new Sha256 ( key ) ;
87
87
hash . update ( data ) ;
88
88
expect ( await hash . digest ( ) ) . to . deep . equal ( result ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ A consistent interface for SHA256 across browsers and NodeJs
4
4
5
5
## Usage
6
6
7
+ - To hash "some data"
7
8
```
8
9
import {Sha256} from '@aws-crypto/sha256-universal'
9
10
@@ -13,6 +14,16 @@ const result = await hash.digest();
13
14
14
15
```
15
16
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
+
16
27
## Test
17
28
18
29
` npm test `
You can’t perform that action at this time.
0 commit comments