From a344b940da455bf734765f5e82bffe27acd08870 Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Tue, 30 Jul 2024 16:49:05 +0200 Subject: [PATCH] Encryption new signature svg pdf file --- app.php | 9 ++++++++- lib/cryptography.class.php | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app.php b/app.php index ca1ce44..cd6f9a8 100644 --- a/app.php +++ b/app.php @@ -353,9 +353,16 @@ function($f3) { array_map('unlink', explode(' ', trim($svgFiles))); } + $symmetricKey = ""; + if (isset($_COOKIE[$hash])) { + $symmetricKey = "#k:" . $_COOKIE[$hash]; + $encryptor = new CryptographyClass($_COOKIE[$hash], $f3->get('PDF_STORAGE_PATH').$hash); + $encryptor->encrypt(); + } + \Flash::instance()->setKey('openModal', 'signed'); - $f3->reroute($f3->get('REVERSE_PROXY_URL').'/signature/'.$f3->get('PARAMS.hash')); + $f3->reroute($f3->get('REVERSE_PROXY_URL').'/signature/'.$hash.$symmetricKey); } ); diff --git a/lib/cryptography.class.php b/lib/cryptography.class.php index c0a3d2d..02be4b3 100644 --- a/lib/cryptography.class.php +++ b/lib/cryptography.class.php @@ -16,7 +16,10 @@ private function getFiles($isGpg) { $suffix = ".gpg"; } $filesTab = glob($this->pathHash.'/*.pdf'.$suffix); - $filesTab[] = $this->pathHash."/filename.txt".$suffix; + + if(file_exists($this->pathHash."/filename.txt".$suffix)) { + $filesTab[] = $this->pathHash."/filename.txt".$suffix; + } return $filesTab; }