a
This commit is contained in:
parent
ea55f9e585
commit
eec44d168b
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user