Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
public-encrypt
Advanced tools
Package description
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.
Readme
publicEncrypt/privateDecrypt for browserify
FAQs
browserify version of publicEncrypt & privateDecrypt
The npm package public-encrypt receives a total of 6,752,337 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.