feat: core utilities - CSRF, auth, encryption, PHPMailer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gestoría LP
2026-03-01 23:28:54 +00:00
parent 10bc97e8b9
commit 322fc78f2b
7 changed files with 7299 additions and 0 deletions

17
includes/encryption.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
require_once __DIR__ . '/config.php';
function encryptData(string $plaintext): string {
$iv = random_bytes(16);
$key = hash('sha256', ENCRYPTION_KEY, true);
$encrypted = openssl_encrypt($plaintext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
return base64_encode($iv . $encrypted);
}
function decryptData(string $ciphertext): string {
$data = base64_decode($ciphertext);
$iv = substr($data, 0, 16);
$encrypted = substr($data, 16);
$key = hash('sha256', ENCRYPTION_KEY, true);
return openssl_decrypt($encrypted, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
}