本文环境:
操作系统:windows 64;
node版本:v10.14.0;
参考文档:https://github.com/pubkey/eth-crypto;
npm install g -eth-crypto
// es6
import EthCrypto from 'eth-crypto';
// node
const EthCrypto = require('eth-crypto');
node环境下运行以下代码,可以离线生成账号,得到私钥、公钥和地址。
const EthCrypto = require('eth-crypto');
const identity = EthCrypto.createIdentity();
//可以直接显示私钥、公钥和地址
console.log('privateKey:'+identity.privateKey);
console.log('publicKey: '+identity.publicKey);
console.log('address: '+identity.address);
/* >
privateKey:0xafd2fa1a57103993c16e2318f45206417c5cf840bb204603912b8dc54b7d8800
publicKey: 37b7d