توابع رمزنگاری مورد استفاده:

<?php
function encryptPhp($data, $key) {
    $method = "AES-256-CBC";
    $key = substr(hash("sha256", $key, true), 0, 32);
    $iv = openssl_random_pseudo_bytes(16);
    
    $encrypted = openssl_encrypt(
        $data,
        $method,
        $key,
        OPENSSL_RAW_DATA,
        $iv
    );
    
    return base64_encode($iv . $encrypted);
}

function decryptPhp($data, $key) {
    $method = "AES-256-CBC";
    $key = substr(hash("sha256", $key, true), 0, 32);
    
    $data = base64_decode($data);
    $iv = substr($data, 0, 16);
    $encrypted = substr($data, 16);
    
    return openssl_decrypt(
        $encrypted,
        $method,
        $key,
        OPENSSL_RAW_DATA,
        $iv
    );
}