Update security.php

This commit is contained in:
Namhyeon Go 2018-03-07 13:11:59 +09:00 committed by GitHub
parent ea39c6d7c2
commit e6bb3fbd3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -425,12 +425,20 @@ if(!function_exists("get_callable_token")) {
}
if(!function_exists("encapsulate_text")) {
function encapsulate_text($text, $algo="aes-128-cbc", $key="", $iv="") {
function encapsulate_text($text, $algo="aes-128-cbc", $key="", $iv="", $hash="", $hash_algo="sha1") {
global $config;
$encapsulated_text = "";
$encrypted_text = "";
// when fail hash test
if(!empty($hash)) {
if($hash != get_hashed_text($text, $hash_algo)) {
return $encapsulated_text;
}
}
// initialize text
$init_text = base64_encode($text);
if($algo == "base64") {
@ -452,12 +460,13 @@ if(!function_exists("encapsulate_text")) {
}
if(!function_exists("decapsulate_text")) {
function decapsulate_text($text, $algo="aes-128-cbc", $key="", $iv="") {
function decapsulate_text($text, $algo="aes-128-cbc", $key="", $iv="", $hash="", $hash_algo="sha1") {
global $config;
$decapsulate_text = "";
$decrypted_text = "";
// initialize text
$init_text = base64_decode($text);
if($algo = "base64") {
@ -474,6 +483,13 @@ if(!function_exists("decapsulate_text")) {
}
}
// when fail hash test
if(!empty($hash)) {
if($hash != get_hashed_text($decapsulate_text, $hash_algo)) {
$decapsulate_text = "";
}
}
return $decapsulate_text;
}
}