Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"react-dom": "^18.3.1",
"react-icons": "^5.5.0",
"react-redux": "^9.2.0",
"react-router-dom": "^7.6.2"
"react-router-dom": "^7.6.2",
"crypto-js": "^4.2.0"
},
"devDependencies": {
"@eslint/js": "^9.29.0",
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/infra/LocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ import { type Todo } from '../models/Todo';
import { type User } from '../models/User';

class LocalStorageRepository {
private static encryptionKey = 'your-secure-key'; // Replace with a securely managed key

private static encryptData(data: string): string {
// Implement encryption logic here
return btoa(data); // Example: Base64 encoding (replace with actual encryption)
}

private static decryptData(data: string): string {
// Implement decryption logic here
return atob(data); // Example: Base64 decoding (replace with actual decryption)
}
static getLocalStorageObject<T>(key: string): T | null {
const value = localStorage.getItem(key);
if (value) {
try {
return JSON.parse(value) as T;
const decryptedData = LocalStorageRepository.decryptData(value);
return JSON.parse(decryptedData) as T;
} catch (e) {
throw new Error('Could not parse local storage object');
}
Expand Down Expand Up @@ -48,7 +60,8 @@ class LocalStorageRepository {
}

static setLocalStorageObject<T>(key: string, object: T): void {
localStorage.setItem(key, JSON.stringify(object));
const encryptedData = LocalStorageRepository.encryptData(JSON.stringify(object));
localStorage.setItem(key, encryptedData);
}

static clearAll(): void {
Expand Down