
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
secure-crypto-node-utils
Advanced tools
A collection of essential cryptographic utilities for secure communication in Node.js application. Includes methods for encryption and decryption using AES-256-CBC algorithm with customizable secret keys.
Node Secure Crypto Utils is a comprehensive library providing essential cryptographic utilities for secure communication in Node.js applications. It includes methods for encryption and decryption using the AES-256-CBC algorithm with customizable secret keys, ensuring robust security for your data transmission needs.
To install Node Secure Crypto Utils, you can use npm:
npm install node-secure-crypto-utils
Node Secure Crypto Utils is primarily used to encrypt and decrypt data transmitted between a client and a Node.js server. Here's how you can use it:
Create a .env file to provide the encryption keys in your root directory. The folder structure should be as follows:
|---root
|---bin
| |-- .env
In the .env file, provide the encryption keys:
.env
AES_ENC_SECRET_KEY=your-secret-key
AES_ENC_IV=your-IV-key
Note:
const { encrypt } = require('secure-crypto-node-utils');
// Encrypt sensitive data
const encryptedData = encrypt('Hello World');
const { decrypt } = require('secure-crypto-node-utils');
// Decrypt encrypted data
const decryptedData = decrypt(encryptedData);
To enable encryption and decryption for request and response handling, follow these steps:
To decrypt incoming request data, utilize middleware in your routes file. For example my folder structure is organized as follows:
|---root
|---bin
| |-- .env
|---middlewares
| |-- default.mw.js
|---routes.js
In your routes.js file, require and use the decryption middleware:
var defaultMiddleware = require("middlewares/default.mw.js");
router.use(defaultMiddleware.DecryptHandler);
// declare your API endpoint below
And in your default.mw.js middleware file:
middlewareObj.DecryptHandler = async function (req, res, next) {
// if you need to omit encryption you can use like below
if (req.path == '/test' || req.path == '/test2') {
req.is_no_enc = true;
}else{
// Decrypt encrypted data
req.body = await decrypt(req.body.data);
}
next();
}
To encrypt the response data before sending it to the client, set up a function like below and call it within your API route handler while preparing the response. Ensure to use your encryption methods provided by secure-crypto-node-utils.
async function sendResponse(req, res, response) {
// you can add your conditions to process response
response = { data: await encrypt(response) };
res.json(response);
}
FAQs
A collection of essential cryptographic utilities for secure communication in Node.js application. Includes methods for encryption and decryption using AES-256-CBC algorithm with customizable secret keys.
We found that secure-crypto-node-utils 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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.