
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
secure-encrypt
Advanced tools
A package that simplifies data encryption and decryption, supporting various algorithms and providing a straightforward API for developers.
secure-encrypt is an npm package designed for use with ES6 (JavaScript) and TypeScript, providing a versatile encryption and decryption functionality. It supports three different encryption techniques: character substitution, hexadecimal encoding, and Caesar shift. By combining these methods, secure-encrypt offers a robust and customizable encryption solution.
To install secure-encrypt in your ES6 (JavaScript) or TypeScript project, use the following npm command:
npm install secure-encrypt
or,
yarn add secure-encrypt
import { encrypt, decrypt } from 'secure-encrypt';
To encrypt a plaintext message, use the encrypt function:
const plaintext = "Hello, World!";
const secretKey = "mySecretKey";
const encryptedText = encrypt(plaintext, secretKey);
console.log("Encrypted Text:", encryptedText);
To decrypt an encrypted message, use the decrypt function:
const encryptedText = "encryptedTextHere";
const secretKey = "mySecretKey";
const decryptedText = decrypt(encryptedText, secretKey);
console.log("Decrypted Text:", decryptedText);
Here's the documentation for file message encryption and decryption using the secure-encrypt npm package:
To encrypt the content of a file using secure-encrypt, follow these steps:
Import Module:
Import the encrypt function from the secure-encrypt package.
import { encrypt } from 'secure-encrypt';
Read File Content: Use a function to read the text content from the file.
const fs = require('fs');
const readFromFile = (filePath) => {
return fs.readFileSync(filePath, 'utf8');
};
Encrypt and Write to File:
Encrypt the content obtained from the file using the encrypt function and write the encrypted text back to the file.
const encryptFile = (filePath, secretKey) => {
const plaintext = readFromFile(filePath);
const encryptedText = encrypt(plaintext, secretKey);
writeToFile(filePath, encryptedText);
console.log('Encryption completed. Encrypted text is written to', filePath);
};
Execute Encryption:
Call the encryptFile function with the file path and the secret key.
const inputFilePath = 'input.txt';
const secretKey = 'mySecretKey';
encryptFile(inputFilePath, secretKey);
To decrypt the content of an encrypted file using secure-encrypt, follow these steps:
Import Module:
Import the decrypt function from the secure-encrypt package.
import { decrypt } from 'secure-encrypt';
Decrypt and Write to File:
Decrypt the content obtained from the encrypted file using the decrypt function and write the decrypted text back to the file.
const decryptFile = (filePath, secretKey) => {
const encryptedText = readFromFile(filePath);
const decryptedText = decrypt(encryptedText, secretKey);
writeToFile(filePath, decryptedText);
console.log('Decryption completed. Decrypted text is written to', filePath);
};
Execute Decryption:
Call the decryptFile function with the file path and the secret key.
const inputFilePath = 'input.txt'; // Path to the encrypted file
const secretKey = 'mySecretKey';
decryptFile(inputFilePath, secretKey);
const fs = require('fs');
const { encrypt, decrypt } = require('secure-encrypt');
// Function to read text from a file
const readFromFile = (filePath) => {
return fs.readFileSync(filePath, 'utf8');
};
// Function to write text to a file
const writeToFile = (filePath, data) => {
fs.writeFileSync(filePath, data, 'utf8');
};
// Function to encrypt the content of a file and overwrite it
const encryptFile = (filePath, secretKey) => {
const plaintext = readFromFile(filePath);
const encryptedText = encrypt(plaintext, secretKey);
writeToFile(filePath, encryptedText);
console.log('Encryption completed. Encrypted text is written to', filePath);
};
// Function to decrypt the content of a file and overwrite it
const decryptFile = (filePath, secretKey) => {
const encryptedText = readFromFile(filePath);
const decryptedText = decrypt(encryptedText, secretKey);
writeToFile(filePath, decryptedText);
console.log('Decryption completed. Decrypted text is written to', filePath);
};
// Input file path
const inputFilePath = 'input.txt'; // Replace 'input.txt' with the path to your file
// Secret key
const secretKey = 'mySecretKey'; // Replace 'mySecretKey' with your secret key
// Encrypt the content of the file
encryptFile(inputFilePath, secretKey);
// Decrypt the content of the file
decryptFile(inputFilePath, secretKey);
Ensure you replace 'input.txt' with the actual path to your file and 'mySecretKey' with your secret key before executing the code.
encrypt(plaintext, secretKey) Encrypts the provided plaintext using the specified secret key.
plaintext (string): The text to encrypt.secretKey (string): The secret key for encryption.decrypt(encryptedText, secretKey) Decrypts the provided encrypted text using the specified secret key.
encryptedText (string): The text to decrypt (base64-encoded).secretKey (string): The secret key for decryption.For bug reports, feature requests, or general inquiries, please create an issue on the GitHub repository.
Contributions are welcome! Fork the repository, make your changes, and submit a pull request.
The secure-encrypt package is inspired by the need for a versatile encryption solution with a combination of different techniques.
FAQs
A package that simplifies data encryption and decryption, supporting various algorithms and providing a straightforward API for developers.
The npm package secure-encrypt receives a total of 19 weekly downloads. As such, secure-encrypt popularity was classified as not popular.
We found that secure-encrypt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.