Update top JS snippets

This commit is contained in:
Chalarangelo
2021-10-13 20:09:28 +03:00
parent 2b775e3c93
commit 3cd481c0d1
19 changed files with 45 additions and 43 deletions

View File

@ -2,7 +2,7 @@
title: hashNode
tags: node,promise,advanced
firstSeen: 2018-01-17T14:09:01+02:00
lastUpdated: 2020-10-19T22:30:46+03:00
lastUpdated: 2021-10-13T19:29:39+02:00
---
Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm.
@ -10,7 +10,7 @@ Returns a promise.
- Use `crypto.createHash()` to create a `Hash` object with the appropriate algorithm.
- Use `hash.update()` to add the data from `val` to the `Hash`, `hash.digest()` to calculate the digest of the data.
- Use `setTimeout()` to prevent blocking on a long operation, and return a `Promise` to give it a familiar interface.
- Use `setTimeout()` to prevent blocking on a long operation. Return a `Promise` to give it a familiar interface.
```js
const crypto = require('crypto');