create a sha3_256 hash from a string in javascript

You can use the crypto module in Node.js to create SHA3-256 hash from a string. First, you need to import the crypto module:

index.tsx
const crypto = require('crypto');
34 chars
2 lines

Then, you can create a hash object and update it with the input string. Finally, you can call the digest method to get the final hash value in hex format:

index.tsx
const inputString = 'hello world';
const hash = crypto.createHash('sha3-256');
hash.update(inputString);
const hexHash = hash.digest('hex');
console.log(hexHash);
163 chars
6 lines

This will output the SHA3-256 hash value of the input string in hex format.

gistlibby LogSnag