Does anyone know do there have any way that I can encrypt the array in php??
for example:
$arr_value = array("1","2","3","4");
any way that I can encrypt $arr_value, also decrypt it later ini php?
Does anyone know do there have any way that I can encrypt the array in php??
for example:
$arr_value = array("1","2","3","4");
any way that I can encrypt $arr_value, also decrypt it later ini php?
You can encrypt/decrypt something like this:
$arr_value = array("1","2","3","4");
function encrypt($text)
{
return base64_encode($text);
}
function decrypt($text)
{
return base64_decode($text);
}
Now to encrypt:
$encrypted = array_map("encrypt", $arr_value);
echo '<pre>';
print_r($encrypted);
And to decrypt:
$decrypted = array_map("decrypt", $arr_value);
echo '<pre>';
print_r($decrypted);
.
Note:
It is worth having a look at a better way of encryption library:
if you encrypt/decrypt string then use .
$str_value = $arr_value.join(",");
encrypt/decrypt $str_value
$arr_value=$str_value.split(",")