
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
public-encrypt
Advanced tools
The public-encrypt npm package provides functionality for asymmetric encryption and decryption using public and private keys. It allows users to encrypt data with a public key that can only be decrypted with the corresponding private key, and vice versa.
Public Key Encryption
This feature allows you to encrypt data using a public key. The encrypted data can only be decrypted by someone with the corresponding private key.
const { publicEncrypt } = require('public-encrypt');
const { publicKey, privateKey } = require('crypto').generateKeyPairSync('rsa', { modulusLength: 2048 });
const encryptedData = publicEncrypt(publicKey, Buffer.from('Hello, World!'));
console.log(encryptedData);
Private Key Decryption
This feature allows you to decrypt data using a private key that corresponds to the public key used for encryption.
const { privateDecrypt } = require('public-encrypt');
const { publicKey, privateKey } = require('crypto').generateKeyPairSync('rsa', { modulusLength: 2048 });
const encryptedData = publicEncrypt(publicKey, Buffer.from('Hello, World!'));
const decryptedData = privateDecrypt(privateKey, encryptedData);
console.log(decryptedData.toString());
node-rsa is a package that provides similar functionality for RSA encryption and decryption. It offers a more object-oriented approach compared to public-encrypt and includes additional features such as signing and verifying.
forge is a comprehensive library that includes not only public key encryption but also other cryptographic operations. It is more extensive than public-encrypt, providing a full set of tools for encryption, hashing, and TLS.
crypto-browserify is designed to emulate the Node.js crypto module for use in the browser. It includes functionality for public and private key encryption and decryption, similar to public-encrypt, but is tailored for browser environments.
publicEncrypt/privateDecrypt for browserify
FAQs
browserify version of publicEncrypt & privateDecrypt
The npm package public-encrypt receives a total of 7,078,256 weekly downloads. As such, public-encrypt popularity was classified as popular.
We found that public-encrypt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.