File: /var/www/nclive/backend/common_function.php
<?php
function maskMobile($mobile)
{
return substr($mobile, 0, 0)
. str_repeat('*', (strlen($mobile) - 3))
. substr($mobile, -3);
}
function encrypt_data($data)
{
$plaintext = $data;
$password = 'nkwp#8910792313';
$method = "AES-256-CBC";
$key = hash('sha256', $password, true);
$iv = openssl_random_pseudo_bytes(16);
$ciphertext = openssl_encrypt($plaintext, $method, $key, OPENSSL_RAW_DATA, $iv);
$hash = hash_hmac('sha256', $ciphertext, $key, true);
return $iv . $hash . $ciphertext;
}
function decrypt_data($data)
{
$ivHashCiphertext = $data;
$password = 'nkwp#8910792313';
$method = "AES-256-CBC";
$iv = substr($ivHashCiphertext, 0, 16);
$hash = substr($ivHashCiphertext, 16, 32);
$ciphertext = substr($ivHashCiphertext, 48);
$key = hash('sha256', $password, true);
if (hash_hmac('sha256', $ciphertext, $key, true) !== $hash)
return null;
return openssl_decrypt($ciphertext, $method, $key, OPENSSL_RAW_DATA, $iv);
}
function verifyNewMobile($otp, $stPhone)
{
$sender_id = "GRAPOS";
$type = 'NORMAL';
include_once '/var/www/nclive/backend/sendsmsapi.php';
$mnt_message = "OTP to approve registration for Naukri Connect is " . $otp . ". Please do not share this OTP with anyone.\nGraposs Connect";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$obj->sendMessage($sender_id, $stPhone, $encodedMessage, $type, $otp);
return $otp; // return array('status'=>'1','otp'=>$username,'phone'=>$stPhone);
}
?>