<?php
require 'database.php';
$user_check=$_SESSION['user_id'];

$lockmasterqry=mysqli_query($con,"select * from user_master where user_id='$user_check' ");
$lockmasterdata=mysqli_fetch_array($lockmasterqry);

$user_name=$lockmasterdata['user_name'];
$user_email=$lockmasterdata['user_email'];
$user_id=$lockmasterdata['user_id'];
$user_department=$lockmasterdata['user_department'];
$user_photo=$lockmasterdata['user_photo'];
$user_type=$lockmasterdata['user_type'];

if(!isset($user_id))
{
echo '<script> window.location="login"; </script>';
}


function encryptId($id) {
    $key = "my_secret_key_12345"; // change this
    $iv = openssl_random_pseudo_bytes(16);

    $encrypted = openssl_encrypt($id, 'AES-256-CBC', $key, 0, $iv);

    return base64_encode($encrypted . '::' . $iv);
}

function decryptId($encryptedId) {
    $key = "my_secret_key_12345"; // same key

    list($encrypted_data, $iv) = explode('::', base64_decode($encryptedId), 2);

    return openssl_decrypt($encrypted_data, 'AES-256-CBC', $key, 0, $iv);
}

?>