如何使用NodeJS中的公钥encryption数据?

在encryption中,我只看到签名者/validation者进行数字签名和encryption/解密与对称密钥encryption。

如何使用公钥encryption数据?

对于那些遇到这个问题时,谷歌search,另一个SO问题已经回答已经encryption数据与公钥在node.js运作良好。

你可能会对我的NaCl结合感兴趣。 从它的API:

// encrypt and sign box(message, nonce, pubkey, privkey) // decrypt and validate unbox(box, nonce, pubkey, privkey) // generates a new keypair, returns {private: <buffer>, public: <buffer>} boxKeypair() // lengths of nonces and public and private keys in bytes // { nonce: x, pubkey: x, privkey: x } lengths.box