UNPKG

encrypt-stack

Version:

An encryption driver/stack to create a multi-layer encrypted workflow in Node.

12 lines (9 loc) 359 B
'use strict'; const crypto = require("crypto"); module.exports = (method, secret, data)=>{ const iv = crypto.randomBytes(442/8); const cipher = crypto.createCipher(method, secret, iv.toString("hex")); let encrypted = cipher.update(data, "utf8", "hex"); encrypted += cipher.final("hex"); return encrypted + "$//$" + iv.toString("hex"); };