第15篇 账户管理(开源库eth-crypto)

本文环境:

      操作系统:windows 64;

      node版本:v10.14.0;

参考文档:https://github.com/pubkey/eth-crypto

1. 安装

npm install g -eth-crypto
// es6
import EthCrypto from 'eth-crypto';

// node
const EthCrypto = require('eth-crypto');

2. 创建账号

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: 37b7d6

猜你喜欢

转载自blog.csdn.net/wonderBlock/article/details/106897975