Skip to content

Commit

Permalink
fixup! add example
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Oct 15, 2019
1 parent bb039ef commit 0291c30
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,23 @@ specify the desired output length in bytes.
An error is thrown when an attempt is made to copy the `Hash` object after
its [`hash.digest()`][] method has been called.

```js
// Calculate a rolling hash.
const crypto = require('crypto');
const hash = crypto.createHash('sha256');

hash.update('one');
console.log(hash.copy().digest('hex'));

hash.update('two');
console.log(hash.copy().digest('hex'));

hash.update('three');
console.log(hash.copy().digest('hex'));

// Etc.
```

### hash.digest(\[encoding\])
<!-- YAML
added: v0.1.92
Expand Down

0 comments on commit 0291c30

Please sign in to comment.