From 19068a9f6a6ff8aa243d3dcce069ed7e8c0e3b41 Mon Sep 17 00:00:00 2001 From: Gaston Gaiduk Date: Wed, 18 Dec 2024 15:37:23 +0100 Subject: [PATCH] Last approach --- .github/workflows/tests.yml | 4 +--- src/utils/crypto.ts | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de35c47..a50c198 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,6 +33,4 @@ jobs: done - name: Run Cypress tests - uses: cypress-io/github-action@v6 - env: - VITE_ENCRYPTION_KEY: '1234567890' \ No newline at end of file + uses: cypress-io/github-action@v6 \ No newline at end of file diff --git a/src/utils/crypto.ts b/src/utils/crypto.ts index e15367d..a195e00 100644 --- a/src/utils/crypto.ts +++ b/src/utils/crypto.ts @@ -1,10 +1,11 @@ import CryptoJS from 'crypto-js'; export function encryptData(data: string): string { - return CryptoJS.AES.encrypt(data, import.meta.env.VITE_ENCRYPTION_KEY as string).toString(); + const encryptionKey = import.meta.env.VITE_ENCRYPTION_KEY as string || 'test_key'; + return CryptoJS.AES.encrypt(data, encryptionKey).toString(); } export function decryptData(ciphertext: string): string { - const bytes = CryptoJS.AES.decrypt(ciphertext, import.meta.env.VITE_ENCRYPTION_KEY as string); + const bytes = CryptoJS.AES.decrypt(ciphertext, import.meta.env.VITE_ENCRYPTION_KEY as string || 'test_key'); return bytes.toString(CryptoJS.enc.Utf8); }