node-rsa
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
asn1 | 0.2.6 | 5.84 kB | MIT | prod |
Node-RSA is a powerful, full-featured RSA library for Node.js. It's based on the jsbn library from Tom Wu. Node-RSA provides pure JavaScript implementation, so there is no need for OpenSSL. Its key features include generating keys, supporting long messages for encryption/decryption, and providing signing and verify functionalities. With Node-RSA, you can effectively carry out encryption/decryption and signing/verifying operations in your Node.js applications.
To use node-rsa, begin by installing the npm package using the command npm install node-rsa
. Once installed, you can import NodeRSA using const NodeRSA = require('node-rsa');
. From there, you can create a new instance and generate a 512bit-length key. For example:
const NodeRSA = require('node-rsa');
const key = new NodeRSA({b: 512});
You can then use this key to encrypt and decrypt messages as follows:
const text = 'Hello RSA!';
const encrypted = key.encrypt(text, 'base64');
console.log('encrypted: ', encrypted);
const decrypted = key.decrypt(encrypted, 'utf8');
console.log('decrypted: ', decrypted);
Node-RSA also allows generating keys from custom parameters, loading keys from PEM strings, importing/exporting key data in several formats, signing/verifying buffers, and more, offering great flexibility for diverse RSA operations.
The node-rsa documentation can be found in the project's README and GitHub repository. It provides installation instructions, usage examples, and detailed information on different methods, giving you a comprehensive guide on how to leverage the full potential of the Node-RSA library.