1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2024-06-03 14:32:13 +02:00
24eme-signaturepdf/lib/cryptography.class.php
2023-11-03 15:13:09 +01:00

35 lines
999 B
PHP

<?php
class CryptographyClass
{
public function encrypt($hash) {
$key = "test";
foreach (glob("/tmp/".$hash.'/*.pdf') as $file) {
$outputFile = $file.".gpg";
$command = "echo '$key' | gpg --batch --passphrase-fd 0 --symmetric --cipher-algo AES256 -o $outputFile $file";
$result = shell_exec($command);
if ($result === false) {
echo "Cypher failure";
exit;
}
unlink($file);
}
}
public function decrypt($hash) {
$key = "test";
foreach (glob("/tmp/".$hash.'/*.gpg') as $file) {
$outputFile = str_replace(".gpg", "", $file);
$command = "echo '$key' | gpg --batch --passphrase-fd 0 --decrypt -o $outputFile $file";
$result = shell_exec($command);
if ($result === false) {
echo "Decypher failure";
exit;
}
unlink($file);
}
}
}
?>