From 70c89fe4c1fc923055a2b15b66648b7fcd51ed47 Mon Sep 17 00:00:00 2001 From: KANE LAZENI Date: Mon, 23 Feb 2026 23:41:24 +0000 Subject: [PATCH] a --- Contestation/Demandereconnaissancefaciale.php | 24 +++++++++++++++++++ Contestation/verify_facial_api.php | 5 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Contestation/Demandereconnaissancefaciale.php b/Contestation/Demandereconnaissancefaciale.php index a6ba4a6..d3e8b25 100755 --- a/Contestation/Demandereconnaissancefaciale.php +++ b/Contestation/Demandereconnaissancefaciale.php @@ -241,6 +241,30 @@ // echo $message; } + // 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'))); + $plaintext = file_get_contents($sourcePath); + + $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 + } + + // 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'))); + $data = file_get_contents($path); + + $iv = substr($data, 0, 16); + $ciphertext = substr($data, 16); + + // return openssl_decrypt($ciphertext, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); + return base64_encode(openssl_decrypt($ciphertext, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv)); + } ?> diff --git a/Contestation/verify_facial_api.php b/Contestation/verify_facial_api.php index 36e6fc9..7e2e632 100644 --- a/Contestation/verify_facial_api.php +++ b/Contestation/verify_facial_api.php @@ -62,15 +62,16 @@ class FacialVerificationAPI { array( "referenceImagePath" => $referenceImagePath, "capturedImageBase64" => $capturedImageBase64, + "photoAssureCrypte" => $_SESSION['photoAssureCrypte'], ) ); exit; // Option 1: Azure Face API (Recommandé) - return $this->compareWithAzureFaceAPI($referenceImagePath, $capturedImageBase64); + // return $this->compareWithAzureFaceAPI($referenceImagePath, $capturedImageBase64); // Option 2: AWS Rekognition - // return $this->compareWithAWSRekognition($referenceImagePath, $capturedImageBase64); + return $this->compareWithAWSRekognition($referenceImagePath, $capturedImageBase64); // Option 3: Solution locale avec OpenCV/dlib (avancé) // return $this->compareWithLocalFaceRecognition($referenceImagePath, $capturedImageBase64);