Encrypting data with a public key in Node.js

前端 未结 6 847
不思量自难忘°
不思量自难忘° 2020-11-29 16:13

I need to encrypt a string using a public key (.pem file), and then sign it using a private key (also a .pem).

I am loading the .pem files fine:

public         


        
6条回答
  •  北海茫月
    2020-11-29 17:15

    This is not supported natively by Node.js version v0.11.13 or below, but it seems that next version of Node.js (a.k.a v0.12) will support this.

    Here is the clue: https://github.com/joyent/node/blob/v0.12/lib/crypto.js#L358

    See crypto.publicEncrypt and crypto.privateDecrypt

    Here is the future documentation for this https://github.com/joyent/node/blob/7c0419730b237dbfa0ec4e6fb33a99ff01825a8f/doc/api/crypto.markdown#cryptopublicencryptpublic_key-buffer

提交回复
热议问题