一、将字符串LockDataV分割后,转为16进制(加密);
$string = "LockDataV"; $arr1 = str_split($string, 1); foreach ($arr1 as $akey => $aval) { $arr1[$akey] = "0x" . bin2hex($aval); } echo "<pre>"; var_dump($arr1);
二、将分割后的数组,转成16进制ascii码转换成字符(解密)
$arrs1 = [0x4c, 0x6f, 0x63, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x56]; $arr2 = $arr1; foreach ($arr2 as $skey => $sval) { $arr2[$skey] = chr($sval); } echo "<pre>"; var_dump($arr2);
三、字符转化为字符串
echo "<pre>"; $arr3 = implode("", $arr2); var_dump($arr3);