Update -> refactor and optimize UI , code ,...

This commit is contained in:
2026-04-10 11:35:25 +03:30
parent 3327207f05
commit 0de951fd91
20 changed files with 1085 additions and 282 deletions

View File

@@ -1,15 +1,32 @@
<?php
function encryptText($text, $key) {
$iv = random_bytes(16);
function encryptText(string $text, string $key): array
{
$iv = random_bytes(16);
$cipher = openssl_encrypt($text, 'AES-256-CBC', $key, 0, $iv);
if ($cipher === false) {
throw new RuntimeException('Encryption failed.');
}
return [
'cipher' => $cipher,
'iv' => base64_encode($iv)
'iv' => base64_encode($iv),
];
}
function decryptText($cipher, $iv, $key) {
function decryptText(string $cipher, string $iv, string $key): string|false
{
return openssl_decrypt($cipher, 'AES-256-CBC', $key, 0, base64_decode($iv));
}
function generateId() {
function generateId(): string
{
return bin2hex(random_bytes(16));
}
function jsonResponse(array $data, int $status = 200): void
{
http_response_code($status);
header('Content-Type: application/json');
echo json_encode($data);
exit;
}