Skip to content

Commit

Permalink
Last approach
Browse files Browse the repository at this point in the history
  • Loading branch information
gastongaiduk committed Dec 18, 2024
1 parent a134135 commit 19068a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ jobs:
done
- name: Run Cypress tests
uses: cypress-io/github-action@v6
env:
VITE_ENCRYPTION_KEY: '1234567890'
uses: cypress-io/github-action@v6
5 changes: 3 additions & 2 deletions src/utils/crypto.ts
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 19068a9

Please sign in to comment.