public/subjects/blockchain/hash-file
nprimo e35fb4b029 docs(hash-file): update subject
add space for format
2023-03-21 10:07:53 +00:00
..
README.md docs(hash-file): update subject 2023-03-21 10:07:53 +00:00

README.md

hash-file

Instructions

Create a function hashFile(fpath) that given the name of a file in the current folder, expected to be a string, returns the hash sha256 of the content of this file as a string.

Here an example on how you should make your function used from external scripts:

exports.hasFile = ...

Usage

Here below an example of main.js script to test the usage of the hashFile function:

const hash = await hashFile('textfile.txt')
console.log(hash)

And its usage:

$ cat textfile.txt
Sometimes science is more art than science.$
Sometimes science is more art than science.
$ node main.js
bd9ecabfb0c9a310cbca5ef1dd6456486236ba58a1d8a4eaf2b0a40283525cd9
$

Notions