This commit is contained in:
2026-09-12 11:12:31 +02:00
parent 09ab527a93
commit bb0bf658ed
6 changed files with 208 additions and 107 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ function is_https_request(): bool {
/**
* AES-256-GCM / AES-256-CBC encryptie helper voor gevoelige tokens (OAuth, API keys)
*/
function fociz_encrypt(string $plaintext): string {
function fociz_encrypt(?string $plaintext): string {
if (empty($plaintext)) return '';
$key = hash('sha256', defined('APP_SECRET') ? APP_SECRET : 'fociz-maria-db-super-secret-key-998877', true);
$iv = random_bytes(16);
@@ -46,7 +46,7 @@ function fociz_encrypt(string $plaintext): string {
/**
* AES-256-CBC decryptie helper; decodeert indien versleuteld, laat legacy plaintext ongemoeid
*/
function fociz_decrypt(string $ciphertext): string {
function fociz_decrypt(?string $ciphertext): string {
if (empty($ciphertext)) return '';
if (!str_starts_with($ciphertext, 'ENC:')) {
return $ciphertext; // Plaintext legacy waarde