@@ -45,9 +45,23 @@ A standalone file [noble-hashes.js](https://github.com/paulmillr/noble-hashes/re
45
45
``` js
46
46
// import * from '@noble/hashes'; // Error: use sub-imports, to ensure small app size
47
47
import { sha256 } from ' @noble/hashes/sha2' ; // ECMAScript modules (ESM) and Common.js
48
- console .log (sha256 (new Uint8Array ([1 , 2 , 3 ]))); // Uint8Array(32) [3, 144, 88, 198, 242...]
49
- // strings are also accepted and auto-encoded into u8a
50
- console .log (sha256 (' abc' )); // == sha256(new TextEncoder().encode('abc'))
48
+ sha256 (new Uint8Array ([1 , 2 , 3 ]); // returns Uint8Array
49
+ sha256 (' abc' ); // == sha256(new TextEncoder().encode('abc'))
50
+
51
+ // Other imports
52
+ import { sha256 , sha384 , sha512 , sha224 , sha512_256 , sha512_384 } from ' @noble/hashes/sha2' ;
53
+ import { sha3_256 , sha3_512 , keccak_256 , keccak_512 , shake128 , shake256 } from ' @noble/hashes/sha3' ;
54
+ import * as sha3_addons from ' @noble/hashes/sha3-addons' ;
55
+ import { ripemd160 } from ' @noble/hashes/ripemd160' ;
56
+ import { blake3 } from ' @noble/hashes/blake3' ;
57
+ import { blake2b } from ' @noble/hashes/blake2b' ;
58
+ import { blake2s } from ' @noble/hashes/blake2s' ;
59
+ import { blake256 , blake512 } from ' @noble/hashes/blake1' ;
60
+ import { hmac } from ' @noble/hashes/hmac' ;
61
+ import { hkdf } from ' @noble/hashes/hkdf' ;
62
+ import { pbkdf2 , pbkdf2Async } from ' @noble/hashes/pbkdf2' ;
63
+ import { scrypt , scryptAsync } from ' @noble/hashes/scrypt' ;
64
+ import * as utils from ' @noble/hashes/utils' ;
51
65
` ` `
52
66
53
67
- [Implementations](#implementations)
@@ -58,7 +72,6 @@ console.log(sha256('abc')); // == sha256(new TextEncoder().encode('abc'))
58
72
- MACs: [hmac](#hmac) (also sha3-addons [kmac](#sha3-addons-cshake-kmac-k12-m14-turboshake), blake3 [key mode](#blake2b-blake2s-blake3))
59
73
- KDFs: [hkdf](#hkdf) | [pbkdf2](#pbkdf2) | [scrypt](#scrypt) | [argon2](#argon2)
60
74
- [utils](#utils)
61
- - [ All available imports] ( #all-available-imports )
62
75
- [Security](#security) | [Speed](#speed) | [Contributing & testing](#contributing--testing) | [License](#license)
63
76
64
77
### Implementations
@@ -355,40 +368,6 @@ console.log(toHex(randomBytes(32)));
355
368
- ` bytesToHex` will convert ` Uint8Array ` to a hex string
356
369
- ` randomBytes (bytes)` will produce cryptographically secure random ` Uint8Array ` of length ` bytes`
357
370
358
- #### All available imports
359
-
360
- ``` js
361
- import { sha256 , sha384 , sha512 , sha224 , sha512_256 , sha512_384 } from ' @noble/hashes/sha2' ;
362
- // prettier-ignore
363
- import {
364
- sha3_224 , sha3_256 , sha3_384 , sha3_512 ,
365
- keccak_224 , keccak_256 , keccak_384 , keccak_512 ,
366
- shake128 , shake256
367
- } from ' @noble/hashes/sha3' ;
368
- // prettier-ignore
369
- import {
370
- cshake128 , cshake256 ,
371
- turboshake128 , turboshake256 ,
372
- kmac128 , kmac256 ,
373
- tuplehash256 , parallelhash256 ,
374
- k12 , m14 , keccakprg
375
- } from ' @noble/hashes/sha3-addons' ;
376
- import { ripemd160 } from ' @noble/hashes/ripemd160' ;
377
- import { blake3 } from ' @noble/hashes/blake3' ;
378
- import { blake2b } from ' @noble/hashes/blake2b' ;
379
- import { blake2s } from ' @noble/hashes/blake2s' ;
380
- import { hmac } from ' @noble/hashes/hmac' ;
381
- import { hkdf } from ' @noble/hashes/hkdf' ;
382
- import { pbkdf2 , pbkdf2Async } from ' @noble/hashes/pbkdf2' ;
383
- import { scrypt , scryptAsync } from ' @noble/hashes/scrypt' ;
384
-
385
- import { sha1 } from ' @noble/hashes/sha1' ; // legacy
386
-
387
- // small utility method that converts bytes to hex
388
- import { bytesToHex as toHex } from ' @noble/hashes/utils' ;
389
- console .log (toHex (sha256 (' abc' ))); // ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
390
- ```
391
-
392
371
## Security
393
372
394
373
The library has been independently audited:
@@ -400,7 +379,7 @@ The library has been independently audited:
400
379
- The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io)
401
380
402
381
It is tested against property-based, cross-library and Wycheproof vectors,
403
- and has fuzzing by [ Guido Vranken's cryptofuzz ] ( https://github.com/guidovranken/cryptofuzz ) .
382
+ and is being fuzzed in [the separate repo ](https://github.com/paulmillr/fuzzing ).
404
383
405
384
If you see anything unusual: investigate and report.
406
385
0 commit comments