<?
php
function hex_encode(
$s) {
$s =
iconv('UTF-8', 'GBK',
$s);
return preg_replace('/(.)/es', "str_pad(dechex(ord('\\1')),2,'0',STR_PAD_LEFT)",
$s);
}
function hex_decode(
$s) {
return preg_replace('/(\w{2})/e', "chr(hexdec('\\1'))",
$s);
}
var_dump(hex_encode("李照耀"
));
var_dump(hex_decode("c0eed5d5d2ab"
));
?>
转载于:https://www.cnblogs.com/lizhaoyao/p/5832898.html
相关资源:ComToKey源代码(包含各种指令集的中文解码)