Skip to content

Instantly share code, notes, and snippets.

View Kishore007raj's full-sized avatar
💭
Work hard like Rock Lee!!✌️🔥🔥

M.Kishoreraj Kishore007raj

💭
Work hard like Rock Lee!!✌️🔥🔥
View GitHub Profile
@Kishore007raj
Kishore007raj / encryption.js
Created April 2, 2024 14:26 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);