UNPKG

prisma-encrypter

Version:

Lightweight encryption solution for Prisma

18 lines 756 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decrypt = decrypt; exports.encrypt = encrypt; const crypto_1 = require("crypto"); function decrypt(data, key, iv = '0000000000000000', algorithm = 'aes-256-cbc') { const decipher = (0, crypto_1.createDecipheriv)(algorithm, key, Buffer.from(iv, 'utf8')); let dec = decipher.update(data, 'hex', 'utf8'); dec += decipher.final('utf8'); return dec; } function encrypt(data, key, iv = '0000000000000000', algorithm = 'aes-256-cbc') { const cipher = (0, crypto_1.createCipheriv)(algorithm, key, Buffer.from(iv, 'utf8')); let enc = cipher.update(data, 'utf-8', 'hex'); enc += cipher.final('hex'); return enc; } //# sourceMappingURL=crypter.js.map