encrypt/decrypt rsa with streams
This module is a bit silly unless you are using it as a wrapper because you shouldn't encrypt too many bytes with asymmetric crypto. Instead, encrypt a key for a symmetric cipher in a short header and then switch to symmetric crypto for the payload.
You should probably be using hybrid-rsa-stream instead.
var rsa = ;var fs = ;var pubkey = fs;var enc = rsa;processstdin;
$ echo beep boop | node enc.js ~/.ssh/id_rsa.pubt1Lytqy7CoONohuzIDxoGpErAK4vN9xKWWO/IK4yH/2PvAOIldSAdNg/HhiAWg5PAPwCTSIfINYlpNSQgkw3kK/GtaeEIpAdRnlHh6wNzBcbT7L7R+EZthWzPKpPE9IO0tPM5kBpN8SDr16Z6PC0OxK5ArJAqmbv8hiWzjS384dMYcyYrK6Z0cUawkC2oeZhBf5z6ev1OLTesPF71evJSTIFD3XlbksziAgYIS4CAG+Gwx0avmHwJHnHuvAr/wY3FcVYc4788tmS1YVmRAPrqg/0UoGglnLaSR1DdOJNgw5y/oErlBxXtMV6jEjWLi8XK2hZiKk/ecA921Fx+483zw==
var rsa = ;var fs = ;var privkey = fs;var dec = rsa;processstdin;
$ echo beep boop | node enc.js ~/.ssh/id_rsa.pub | node dec.js ~/.ssh/id_rsaEnter PEM pass phrase:beep boop
var rsa =
Return an encryption stream
enc that will encrypt the data written to it with
publicKey and output the encrypted stream with
('binary' buffers by default).
publicKey should be a string or buffer with PEM key data or the openssh-style
public keys typically found in ~/.ssh that begin with
If more than
opts.limit bytes are written, an error is thrown. The default
number of bytes is 100, which you should only raise to maximally
n/8-11 for an
n-bit RSA key.
Return a decryption stream
dec that will decrypt the data written to it in
opts.encoding format with the given
privateKey should be a string or buffer with PEM or openssh-style
To get the library, with npm do:
npm install rsa-stream