current position:Home>How to introduce the hash library keccak? I installed it according to NPM install keccak -- save, but the execution code will report an error

How to introduce the hash library keccak? I installed it according to NPM install keccak -- save, but the execution code will report an error

2022-02-03 20:57:49 Q & A of Denglian community

// Encryption library var Crypto = require('crypto')// Elliptic curve library var secp256k1 = require('secp256k1')// Hashiku var createKeccakHash = require('keccak')

// One 32 Random number of bytes (1~2^256--1), Just use it as a private key var privateKey = Crypto.randomBytes(32)

// from secp256kl Elliptic curve algorithm first calculates the public key var pubKey = secp256k1.publicKeyCreate(privateKey,false).slice(1);

// Conduct keccak256hash After operation and retrieval 40 You get var address = createKeccakHash('keccak256').update(pubKey).digest().slice(-20);

console.log(privateKey.toString('hex'));console.log("0x" + address.toString('hex'));






Other answers 1:


Other answers 2:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032057474901.html

Random recommended