The hashBlock method

Let's build up our hashBlock method. Inside of this method, we want to use SHA256 hashing to hash our block data. Follow the below mentioned steps: 

  1. To use an SHA256 hashing function, import it as an npm library. To do that, go to Google and type SHA256 into the search bar, or visit https://www.npmjs.com/package/sha256. On this website, you will get to see the command that we need to type into our terminal to install SHA256. We'll have to type in the following command in our terminal: 
npm i sha 256--save
  1. After doing this, press Enter. The --save  in the following command will save this library as a dependency for us. Now, inside of our blockchain file structure, you may see that the node_modules folder has appeared. ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.