What is browserify-rsa?
The browserify-rsa package is a Node.js module that provides functionality for RSA encryption and decryption, specifically tailored for use with Browserify. It allows users to perform RSA public and private key operations in a way that is compatible with web browsers.
What are browserify-rsa's main functionalities?
RSA padding
This feature allows for RSA padding when encrypting data. The code sample demonstrates how to use the browserify-rsa package to pad a message using a private key before encryption.
const parseKeys = require('parse-asn1');
const browserifyRsa = require('browserify-rsa');
const privateKey = parseKeys(privateKeyAsn1);
const paddedMessage = browserifyRsa(privateKey, bufferToEncrypt);
RSA decryption
This feature is used for RSA decryption. The code sample shows how to use the browserify-rsa package to decrypt a message using a private key.
const parseKeys = require('parse-asn1');
const browserifyRsa = require('browserify-rsa');
const privateKey = parseKeys(privateKeyAsn1);
const decryptedMessage = browserifyRsa(privateKey, bufferToDecrypt);
Other packages similar to browserify-rsa
node-rsa
node-rsa is a Node.js package that provides RSA encryption, decryption, signing, and verification. It offers a wider range of key formats and more comprehensive functionality compared to browserify-rsa.
forge
forge is a JavaScript library that includes a variety of cryptographic operations including RSA encryption and decryption. It is more feature-rich and not limited to Browserify, unlike browserify-rsa which is tailored for Browserify.
ursa
ursa is a Node.js package that provides bindings to OpenSSL for RSA cryptography. It is more performant for server-side operations as it leverages native code, but it is not designed for browser environments like browserify-rsa.
browserify-rsa
RSA private decryption/signing using chinese remainder and blinding.
API
Give it a message as a Buffer and a private key (as decoded by ASN.1
) and it returns encrypted data as a Buffer.
LICENSE
MIT