🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 14:27
This commit is contained in:
@@ -13,12 +13,17 @@ final class EncryptionService
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Key should be 32 bytes for aes-256-gcm
|
||||
$this->key = $_ENV['ENCRYPTION_KEY'] ?? '';
|
||||
// Load encryption key from secrets config
|
||||
$secrets = require __DIR__ . '/../../../config/secrets.php';
|
||||
$this->key = $secrets['encryption_key'] ?? '';
|
||||
|
||||
// Ensure key is hexadecimal and convert to binary (32 bytes)
|
||||
if (strlen($this->key) === 64) {
|
||||
$this->key = hex2bin($this->key);
|
||||
}
|
||||
|
||||
if (strlen($this->key) !== 32) {
|
||||
// In a real app, this would be in config/secrets.php
|
||||
// For now, we use a fallback if not set, but warn in production
|
||||
$this->key = hash('sha256', $_ENV['JWT_SECRET'] ?? 'fallback-key');
|
||||
throw new Exception("Security Error: Invalid ENCRYPTION_KEY length. Must be 32 bytes.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user