49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services\ESign;
|
||
|
|
|
||
|
|
use App\Services\Service;
|
||
|
|
use Illuminate\Support\Facades\Storage;
|
||
|
|
|
||
|
|
class EsignPdfService extends Service
|
||
|
|
{
|
||
|
|
public function generateHash(string $filePath): string
|
||
|
|
{
|
||
|
|
$fullPath = Storage::disk('local')->path($filePath);
|
||
|
|
|
||
|
|
return hash_file('sha256', $fullPath);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function verifyIntegrity(string $filePath, string $expectedHash): bool
|
||
|
|
{
|
||
|
|
$actualHash = $this->generateHash($filePath);
|
||
|
|
|
||
|
|
return hash_equals($expectedHash, $actualHash);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function composeSigned(
|
||
|
|
string $originalPath,
|
||
|
|
array $signerImages,
|
||
|
|
array $signFields
|
||
|
|
): string {
|
||
|
|
// FPDI/FPDF 기반 PDF 합성 - 추후 구현
|
||
|
|
// 현재는 원본 파일을 signed 경로로 복사
|
||
|
|
$signedPath = str_replace('originals/', 'signed/', $originalPath);
|
||
|
|
$signedDir = dirname(Storage::disk('local')->path($signedPath));
|
||
|
|
|
||
|
|
if (! is_dir($signedDir)) {
|
||
|
|
mkdir($signedDir, 0755, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
Storage::disk('local')->copy($originalPath, $signedPath);
|
||
|
|
|
||
|
|
return $signedPath;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function addAuditPage(string $pdfPath, array $auditData): string
|
||
|
|
{
|
||
|
|
// 감사 증적 페이지 추가 - 추후 FPDI/FPDF로 구현
|
||
|
|
return $pdfPath;
|
||
|
|
}
|
||
|
|
}
|