@@ -31,10 +31,12 @@ For now, it just uses `crypto`, but will use `sha3` and `blake2`, etc.
3131- [ Examples] ( #examples )
3232 - [ Multihash output] ( #multihash-output )
3333 - [ Raw digest output] ( #raw-digest-output )
34+ - [ Verify a multihash] ( #verify-a-multihash )
3435- [ API] ( #api )
3536 - [ ` multihashing(buf, func, length) ` ] ( #multihashingbuf-func-length )
3637 - [ ` digest(buf, func, length) ` ] ( #digestbuf-func-length )
3738 - [ ` createHash(func, length) ` ] ( #createhashfunc-length )
39+ - [ ` verify(input, buf) ` ] ( #verifyhash-buf )
3840 - [ ` functions ` ] ( #functions )
3941- [ Maintainers] ( #maintainers )
4042- [ Contribute] ( #contribute )
@@ -126,6 +128,20 @@ h.digest()
126128// => <SlowBuffer 14 f3 01 f3 1b e2 43 f3 4c 56 68 93 78 83 77 1f a3 81 00 2f 1a aa 5f 31 b3 f7 8e 50 0b 66 ff 2f 4f 8e a5 e3 c9 f5 a6 1b d0 73 e2 45 2c 48 04 84 b0 2e 03 ...>
127129```
128130
131+ ### Verify a multihash
132+
133+ ``` js
134+ > const right = new Buffer (' beep boop' )
135+ > const wrong = new Buffer (' oops' )
136+ > const hash = multihashing (right, ' sha1' )
137+
138+ > console .log (multihashing .verify (hash, right))
139+ // => true
140+
141+ > console .log (multihashing .verify (hash, wrong))
142+ // => false
143+ ```
144+
129145## API
130146
131147### ` multihashing(buf, func, length) `
@@ -134,6 +150,8 @@ h.digest()
134150
135151### ` createHash(func, length) `
136152
153+ ### ` verify(hash, buf) `
154+
137155### ` functions `
138156
139157An object mapping hexcodes to their hash functions.
0 commit comments