From 5a5facdf40f2ed9cd213edef454bc72ae8c545c0 Mon Sep 17 00:00:00 2001 From: Dominik Korsa Date: Sat, 23 Jan 2021 15:17:36 +0100 Subject: [PATCH] Change encrypt symmetrical split character --- backend/src/utils/crypto.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/utils/crypto.ts b/backend/src/utils/crypto.ts index 783dac5..02feec8 100644 --- a/backend/src/utils/crypto.ts +++ b/backend/src/utils/crypto.ts @@ -27,11 +27,11 @@ export function encryptSymmetrical(value: string, key: string): string { const ivBuffer = crypto.randomBytes(16); const cipher = crypto.createCipheriv('aes-256-cbc', base64url.toBuffer(key), ivBuffer); const encrypted = Buffer.concat([cipher.update(value), cipher.final()]); - return `${base64url.encode(encrypted)}@${base64url.encode(ivBuffer)}`; + return `${base64url.encode(encrypted)}.${base64url.encode(ivBuffer)}`; } export function decryptSymmetrical(encrypted: string, key: string): string { - const [encryptedData, iv] = encrypted.split('@'); + const [encryptedData, iv] = encrypted.split('.'); const ivBuffer = base64url.toBuffer(iv); const encryptedBuffer = base64url.toBuffer(encryptedData); const decipher = crypto.createDecipheriv('aes-256-cbc', base64url.toBuffer(key), ivBuffer);