From 722ae2eb41a1ff70c7e4731c931367f0540bd139 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 7 Mar 2018 11:24:23 +0900 Subject: [PATCH] Update security.php --- system/security.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/system/security.php b/system/security.php index fbef5e6..d577e3c 100644 --- a/system/security.php +++ b/system/security.php @@ -422,6 +422,49 @@ if(!function_exists("get_callable_token")) { } } +if(!function_exists("encapsulate_text")) { + function encapsulate_text($text, $method="aes-128-cbc", $key="", $iv="") { + global $config; + + $encapsulated_text = ""; + $encrypted_text = ""; + + $init_text = base64_encode($text); + $init_key = empty($key) ? $config['masterkey'] : $key; + $init_iv = empty($iv) ? $config['masteriv'] : $iv; + + if(function_exists("openssl_encrypt")) { + $encrypted_text = @openssl_encrypt($init_text , $method, $init_key, true, $init_iv); + if(!empty($encrypted_text)) { + $encapsulated_text = base64_encode($encrypted_text); + } + } + + return $encapsulated_text; + } +} + +if(!function_exists("decapsulate_text")) { + function decapsulate_text($text, $method="aes-128-cbc", $key="", $iv="") { + global $config; + + $decapsulate_text = ""; + $decrypted_text = ""; + + $init_text = base64_decode($text); + $init_key = empty($key) ? $config['masterkey'] : $key; + $init_iv = empty($iv) ? $config['masteriv'] : $iv; + + if(function_exists("openssl_decrypt")) { + $encrypted_text = @openssl_decrypt($init_text , $method, $init_key, true, $init_iv); + if(!empty($encrypted_text)) { + $decapsulate_text = base64_encode($decrypted_text); + } + } + + return $decapsulate_text; + } +} // start session (enable $_SESSION) session_start();