From eec44d168bc526534d8ff544cdf9075efb8cab56 Mon Sep 17 00:00:00 2001 From: KANE LAZENI Date: Sat, 4 Jul 2026 08:19:18 +0000 Subject: [PATCH] a --- Contestation/Assure.php | 6 ++- Contestation/Demandereconnaissancefaciale.php | 50 ++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Contestation/Assure.php b/Contestation/Assure.php index 71aef3a..b558a30 100755 --- a/Contestation/Assure.php +++ b/Contestation/Assure.php @@ -106,8 +106,10 @@ class Assure extends Modelecontestation { dureeTokenReconnaissanceFaciale, dossierPhoto, nbTentativeBiometrie, - lienPhotoFace - FROM societeuser WHERE (codeSociete=?);'; + lienPhotoFace, + crypterPhoto + FROM societeuser + WHERE (codeSociete=?);'; $resultat = $this->executerRequeteAdin($sql, array($codeSociete))->fetch(PDO::FETCH_ASSOC); diff --git a/Contestation/Demandereconnaissancefaciale.php b/Contestation/Demandereconnaissancefaciale.php index 9a08535..d74d182 100755 --- a/Contestation/Demandereconnaissancefaciale.php +++ b/Contestation/Demandereconnaissancefaciale.php @@ -293,6 +293,13 @@ $_SESSION['dossierPhoto'] = $param_societe["dossierPhoto"]; $_SESSION['nbTentative'] = $param_societe["nbTentativeBiometrie"]; $_SESSION['lienPhotoFace'] = $param_societe["lienPhotoFace"]; + $_SESSION['crypterPhoto'] = $param_societe["crypterPhoto"]; + + var_dump( + array( + "crypterPhoto" => $_SESSION['crypterPhoto'], + ) + ); $maxAttempts = $_SESSION['nbTentative']; @@ -364,6 +371,7 @@ } // Chiffrer l’image au moment de l’upload (PHP) + /* function encryptImage($sourcePath, $destPath) { $key = base64_decode(trim(file_get_contents('/var/www/keys/inter-sante-photo.key'))); @@ -374,8 +382,29 @@ file_put_contents($destPath, $iv . $cipher); // concat IV + données } + */ + + function encryptImage($sourcePath, $destPath) + { + $plaintext = file_get_contents($sourcePath); + + if($_SESSION['crypterPhoto']=="1") + { + $key = base64_decode(trim(file_get_contents('/var/www/keys/inter-sante-photo.key'))); + + $iv = openssl_random_pseudo_bytes(16); + $cipher = openssl_encrypt($plaintext, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); + + file_put_contents($destPath, $iv . $cipher); // concat IV + données + } + else + { + file_put_contents($destPath, $plaintext); + } + } // Déchiffrer pour afficher la photo dans INTER-SANTE + /* function decryptImage($path) { $key = base64_decode(trim(file_get_contents('/var/www/keys/inter-sante-photo.key'))); @@ -385,7 +414,26 @@ $ciphertext = substr($data, 16); return base64_encode(openssl_decrypt($ciphertext, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv)); - } + } + */ + + function decryptImage($path) + { + $data = file_get_contents($path); + + if($_SESSION['crypterPhoto']=="1") + { + $key = base64_decode(trim(file_get_contents('/var/www/keys/inter-sante-photo.key'))); + $iv = substr($data, 0, 16); + $ciphertext = substr($data, 16); + return base64_encode(openssl_decrypt($ciphertext, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv)); + } + else + { + return base64_encode($data); + } + } + ?>