From 9862e27fcf2a888d7a4b0f1133d6facd9742c8fe Mon Sep 17 00:00:00 2001
From: steel <mael.acier@ensiie.fr>
Date: Mon, 26 Aug 2024 23:52:21 +0200
Subject: [PATCH] refactor: update encryption algorithm to aes-128-gcm

---
 src/lib/crypto.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts
index 537200c2..46c60716 100644
--- a/src/lib/crypto.ts
+++ b/src/lib/crypto.ts
@@ -2,7 +2,7 @@ import crypto from 'crypto';
 
 // Inspiré de https://github.com/MauriceButler/cryptr/blob/master/index.js
 export default class Cryptr {
-	algorithm = 'aes-256-gcm' as const;
+	algorithm = 'aes-128-gcm' as const;
 	encoding = 'base64' as const;
 	pbkdf2Iterations = 100000;
 	saltLength = 64;
@@ -14,7 +14,8 @@ export default class Cryptr {
 	constructor(public secret: string) {}
 
 	getKey(salt: crypto.BinaryLike) {
-		return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512');
+		// return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 16, 'sha512');
+		return crypto.randomBytes(16);
 	}
 
 	encrypt(value: crypto.BinaryLike) {
-- 
GitLab