From d85279564a1071769243b5c7d27d1d0ffd17442a Mon Sep 17 00:00:00 2001 From: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Tue, 30 Jun 2026 14:42:51 -0400 Subject: [PATCH] Log key for testing --- scripts/encrypt-data.js | 7 ++++--- src/shared/Encrypter.ts | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/encrypt-data.js b/scripts/encrypt-data.js index cbc9dc0..f0e759b 100644 --- a/scripts/encrypt-data.js +++ b/scripts/encrypt-data.js @@ -72,12 +72,13 @@ async function main() { class Encrypter { static initialize(encryptionKey) { - this.key = crypto.scryptSync(encryptionKey, 'salt', 32); + console.log(`Initializing encrypter with key: ${encryptionKey}`); + this.key = encryptionKey; } static encrypt(clearText) { const iv = crypto.randomBytes(16); const cipher = crypto.createCipheriv(this.algorithm, this.key, iv); - const encrypted = cipher.update(clearText.toString(), 'utf8', 'hex'); + const encrypted = cipher.update(clearText, 'utf8', 'hex'); return [ encrypted + cipher.final('hex'), Buffer.from(iv).toString('hex'), @@ -91,7 +92,7 @@ class Encrypter { return decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8'); } static hash(clearText) { - return crypto.createHmac('sha256', this.key).update(clearText.toString()).digest('base64'); + return crypto.createHmac('sha256', this.key).update(clearText).digest('base64'); } } Encrypter.algorithm = 'aes-256-cbc'; diff --git a/src/shared/Encrypter.ts b/src/shared/Encrypter.ts index e9047fc..5df8859 100644 --- a/src/shared/Encrypter.ts +++ b/src/shared/Encrypter.ts @@ -5,10 +5,11 @@ import crypto from 'crypto'; export class Encrypter { private static algorithm = 'aes-256-cbc'; - private static key: Buffer; + private static key: string; static initialize(encryptionKey: string) { - this.key = crypto.scryptSync(encryptionKey, 'salt', 32); + console.log(`Initializing encrypter with key: ${encryptionKey}`); + this.key = encryptionKey; } static encrypt(clearText: string): string {