第15章アカウント管理(オープンソースライブラリeth-crypto)

この記事の環境:

      オペレーティングシステム:Windows 64;

      ノードバージョン: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.アカウントを作成します

ノード環境で次のコードを実行して、アカウントをオフラインで生成し、秘密鍵、公開鍵、およびアドレスを取得します。

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