New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

secure-flow

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

secure-flow - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/cli.js

10

package.json
{
"name": "secure-flow",
"version": "1.0.0",
"version": "1.0.1",
"description": "Secure Flow is a lightweight TypeScript utility package for encryption and decryption using the AES-256-CBC algorithm. This package simplifies the process of securely encrypting and decrypting text, making it easy to integrate strong encryption into your Node.js applications.",
"main": "server.js",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"create-config": "ts-node src/cli.ts",
"dev": "npm run build && nodemon --inspect ./dist/server.js",
"start": "npm run build && node ./dist/server.js"
},
"bin": {
"create-secureflow-config": "./bin/create-secureflow-config.js"
},
"keywords": [

@@ -14,0 +18,0 @@ "encrypt",

@@ -1,3 +0,2 @@

// config.js
export const config = {
export const defaultConfig = {
encryptionAlgorithm: "aes-256-cbc",

@@ -7,1 +6,3 @@ encryptionKey: "12345678901234567890123456789012", // Must be 32 characters

};
export type Config = typeof defaultConfig;
import crypto from "crypto";
import { config } from "./config.js";
import { loadConfig } from './loadConfig.js';
import { Config } from './config.js';
const { encryptionAlgorithm, encryptionKey, iv } = config;
const config: Config = loadConfig();

@@ -10,5 +11,5 @@ // Define return types and parameter types for the functions

const cipher = crypto.createCipheriv(
encryptionAlgorithm,
Buffer.from(encryptionKey),
iv
config.encryptionAlgorithm,
Buffer.from(config.encryptionKey),
config.iv
);

@@ -27,5 +28,5 @@ let encrypted = cipher.update(text, "utf8", "hex");

const decipher = crypto.createDecipheriv(
encryptionAlgorithm,
Buffer.from(encryptionKey),
iv
config.encryptionAlgorithm,
Buffer.from(config.encryptionKey),
config.iv
);

@@ -32,0 +33,0 @@

@@ -6,4 +6,7 @@ import express, { Request, Response, NextFunction } from "express";

app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Middleware to encrypt response
app.use((req: Request, res: Response, next: NextFunction) => {
app.use('/encrypt', (req: Request, res: Response, next: NextFunction) => {
const originalSend = res.send;

@@ -20,4 +23,4 @@ res.send = function (body: any) {

// Sample route
app.get("/", (req: Request, res: Response) => {
res.send("Hello, world!");
app.get("/encrypt", (req: Request, res: Response) => {
res.send(req.body);
});

@@ -27,8 +30,9 @@

app.get("/decrypt", (req: Request, res: Response) => {
const encryptedMessage = encrypt("Hello, World!");
const encryptedMessage = req.body.data;
if (encryptedMessage) {
const decryptedMessage = decrypt(encryptedMessage);
console.log(encryptedMessage);
console.log(decryptedMessage);
res.send(`Decrypted message: ${decryptedMessage}`);
console.log(JSON.parse(decryptedMessage));
res.status(200).json(decryptedMessage);
} else {

@@ -35,0 +39,0 @@ res.status(400).send("No message provided");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc