From 518a9163fb42bf8eaf3490304d5bc88f4d449a99 Mon Sep 17 00:00:00 2001 From: Anton Voylenko Date: Sat, 25 Mar 2023 21:34:09 +0200 Subject: [PATCH] add ENCRYPTION_SECRET variable (#132) --- lib/utils/encrypt-decrypt.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/encrypt-decrypt.js b/lib/utils/encrypt-decrypt.js index ae78087..5cb3e55 100644 --- a/lib/utils/encrypt-decrypt.js +++ b/lib/utils/encrypt-decrypt.js @@ -2,9 +2,9 @@ const crypto = require('crypto'); const algorithm = process.env.LEGACY_CRYPTO ? 'aes-256-ctr' : 'aes-256-cbc'; const iv = crypto.randomBytes(16); const secretKey = crypto.createHash('sha256') - .update(String(process.env.JWT_SECRET)) + .update(process.env.ENCRYPTION_SECRET || process.env.JWT_SECRET) .digest('base64') - .substr(0, 32); + .substring(0, 32); const encrypt = (text) => { const cipher = crypto.createCipheriv(algorithm, secretKey, iv);