This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import crypto module | |
const crypto = require("crypto") | |
// use cryptographically secure random bytes generation | |
const preimage = crypto.randomBytes(32) | |
// get the raw bytes from the buffer | |
const preimageRaw = JSON.parse(JSON.stringify(preimage)).data | |
// log the preimage raw bytes | |
console.log(`preimage bytes: ${preimageRaw}`) | |
// create SHA-256 hash | |
const hash = crypto.createHash('sha256') |