first commit

This commit is contained in:
2024-01-08 09:33:24 +07:00
commit ed1d4a2b08
2369 changed files with 875560 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
<?php if (!defined("BASEPATH")) exit("No direct script access allowed");
function encrypt_url($string) {
$output = false;
/*
* read security.ini file & get encryption_key | iv | encryption_mechanism value for generating encryption code
*/
$security = parse_ini_file("security.ini");
$secret_key = $security["encryption_key"];
$secret_iv = $security["iv"];
$encrypt_method = $security["encryption_mechanism"];
// hash
$key = hash("sha256", $secret_key);
// iv encrypt method AES-256-CBC expects 16 bytes else you will get a warning
$iv = substr(hash("sha256", $secret_iv), 0, 16);
//do the encryption given text/string/number
$result = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($result);
return $output;
}
function decrypt_url($string) {
$output = false;
/*
* read security.ini file & get encryption_key | iv | encryption_mechanism value for generating encryption code
*/
$security = parse_ini_file("security.ini");
$secret_key = $security["encryption_key"];
$secret_iv = $security["iv"];
$encrypt_method = $security["encryption_mechanism"];
// hash
$key = hash("sha256", $secret_key);
// iv encrypt method AES-256-CBC expects 16 bytes else you will get a warning
$iv = substr(hash("sha256", $secret_iv), 0, 16);
//do the decryption given text/string/number
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
return $output;
}