Skip to content

Commit 1560730

Browse files
committed
readme
1 parent 9887dcb commit 1560730

File tree

1 file changed

+18
-39
lines changed

1 file changed

+18
-39
lines changed

README.md

+18-39
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,23 @@ A standalone file [noble-hashes.js](https://github.com/paulmillr/noble-hashes/re
4545
```js
4646
// import * from '@noble/hashes'; // Error: use sub-imports, to ensure small app size
4747
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';
5165
```
5266
5367
- [Implementations](#implementations)
@@ -58,7 +72,6 @@ console.log(sha256('abc')); // == sha256(new TextEncoder().encode('abc'))
5872
- MACs: [hmac](#hmac) (also sha3-addons [kmac](#sha3-addons-cshake-kmac-k12-m14-turboshake), blake3 [key mode](#blake2b-blake2s-blake3))
5973
- KDFs: [hkdf](#hkdf) | [pbkdf2](#pbkdf2) | [scrypt](#scrypt) | [argon2](#argon2)
6074
- [utils](#utils)
61-
- [All available imports](#all-available-imports)
6275
- [Security](#security) | [Speed](#speed) | [Contributing & testing](#contributing--testing) | [License](#license)
6376
6477
### Implementations
@@ -355,40 +368,6 @@ console.log(toHex(randomBytes(32)));
355368
- `bytesToHex` will convert `Uint8Array` to a hex string
356369
- `randomBytes(bytes)` will produce cryptographically secure random `Uint8Array` of length `bytes`
357370
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-
392371
## Security
393372
394373
The library has been independently audited:
@@ -400,7 +379,7 @@ The library has been independently audited:
400379
- The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io)
401380
402381
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).
404383
405384
If you see anything unusual: investigate and report.
406385

0 commit comments

Comments
 (0)