Update security.php
This commit is contained in:
parent
06010e34b3
commit
f63cfd3a4b
|
@ -191,7 +191,7 @@ if(!check_function_exists("check_hash_algo")) {
|
||||||
|
|
||||||
if(!check_function_exists("get_hashed_text")) {
|
if(!check_function_exists("get_hashed_text")) {
|
||||||
function get_hashed_text($text, $algo="sha1", $options=array()) {
|
function get_hashed_text($text, $algo="sha1", $options=array()) {
|
||||||
$hashed_text = false;
|
$_text = false;
|
||||||
|
|
||||||
// with salt
|
// with salt
|
||||||
if(!array_key_empty("salt", $options)) {
|
if(!array_key_empty("salt", $options)) {
|
||||||
|
@ -213,42 +213,57 @@ if(!check_function_exists("get_hashed_text")) {
|
||||||
// choose algorithm
|
// choose algorithm
|
||||||
switch($algo) {
|
switch($algo) {
|
||||||
case "sha1":
|
case "sha1":
|
||||||
$hashed_text = sha1($text);
|
$_text = sha1($text);
|
||||||
break;
|
break;
|
||||||
case "md5":
|
case "md5":
|
||||||
$hashed_text = md5($text);
|
$_text = md5($text);
|
||||||
break;
|
break;
|
||||||
case "crypt":
|
case "crypt":
|
||||||
$hashed_text = crypt($text);
|
$_text = crypt($text);
|
||||||
break;
|
break;
|
||||||
case "crc32":
|
case "crc32":
|
||||||
if(!array_key_equals("decimal", $options, true)) {
|
if(!array_key_equals("decimal", $options, true)) {
|
||||||
$hashed_text = str_pad(dechex(crc32($text)), 8, '0', STR_PAD_LEFT);
|
$_text = str_pad(dechex(crc32($text)), 8, '0', STR_PAD_LEFT);
|
||||||
} else {
|
} else {
|
||||||
$hashed_text = crc32($text);
|
$_text = crc32($text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "base64":
|
case "base64":
|
||||||
if(!array_key_equals("decode", $options, true)) {
|
if(!array_key_equals("decode", $options, true)) {
|
||||||
$hashed_text = base64_encode($text);
|
$_text = base64_encode($text);
|
||||||
} else {
|
} else {
|
||||||
$hashed_text = base64_decode($text);
|
$_text = base64_decode($text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "sql_password":
|
case "sql_password":
|
||||||
$row = exec_db_fetch("select password(:text) as pw", array(
|
$row = exec_db_fetch("select password(:text) as pw", array(
|
||||||
"text" => $text,
|
"text" => $text,
|
||||||
));
|
));
|
||||||
$hashed_text = get_value_in_array("pw", $row, $hashed_text);
|
$_text = get_value_in_array("pw", $row, $_text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(check_hash_algo($algo)) {
|
if(check_hash_algo($algo)) {
|
||||||
$hashed_text = hash($algo, $text, false);
|
$_text = hash($algo, $text, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hashed_text;
|
return $_text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!check_function_exists("get_compressed_text")) {
|
||||||
|
function get_compressed_text($text, $algo="deflate", $options=array()) {
|
||||||
|
$_text = "";
|
||||||
|
|
||||||
|
switch($algo) {
|
||||||
|
case "deflate":
|
||||||
|
$_text = get_hashed_text(gzdeflate($text), "base64");
|
||||||
|
default:
|
||||||
|
$_text = $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user