This commit is contained in:
KANE LAZENI 2026-07-04 08:19:18 +00:00
parent ea55f9e585
commit eec44d168b
2 changed files with 53 additions and 3 deletions

View File

@ -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);

View File

@ -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 limage au moment de lupload (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);
}
}
?>
<!DOCTYPE html>