web3.eth.accounts.wallet.encrypt - 加密钱包
优质
小牛编辑
124浏览
2023-12-01
加密所有的钱包账户为keystore v3对象。
调用:
web3.eth.accounts.wallet.encrypt(password);
参数:
password - String: The password which will be used for encryption.
返回值:
Array: 加密后的keystore v3对象
示例代码:
web3.eth.accounts.wallet.encrypt('test');
> [ { version: 3,
id: 'dcf8ab05-a314-4e37-b972-bf9b86f91372',
address: '06f702337909c06c82b09b7a22f0a2f0855d1f68',
crypto:
{ ciphertext: '0de804dc63940820f6b3334e5a4bfc8214e27fb30bb7e9b7b74b25cd7eb5c604',
cipherparams: [Object],
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams: [Object],
mac: 'b2aac1485bd6ee1928665642bf8eae9ddfbc039c3a673658933d320bac6952e3' } },
{ version: 3,
id: '9e1c7d24-b919-4428-b10e-0f3ef79f7cf0',
address: 'b5d89661b59a9af0b34f58d19138baa2de48baaf',
crypto:
{ ciphertext: 'd705ebed2a136d9e4db7e5ae70ed1f69d6a57370d5fbe06281eb07615f404410',
cipherparams: [Object],
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams: [Object],
mac: 'af9eca5eb01b0f70e909f824f0e7cdb90c350a802f04a9f6afe056602b92272b' } }
]