如何将字符串编码为十六进制表示



这种编码的类型是什么?"x73164x6fx72141147145x3a154x69x6e153"

如何将"storage:link"字符串编码为上述编码?

您的字符串是十六进制和八进制表示的"存储:链接":

x73164x6fx72141147145x3a154x69x6e153
^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^
hex oct hex hex oct oct oct hex oct hex hex oct

根据这个评论,您可以将二进制字符串转换为十六进制表示的文本,如下所示:

$hexStr = bin2hex("storage:link");       // 73746f726167653a6c696e6b
$hexStr = chunk_split($hexStr, 2, 'x'); // 73x74x6fx72x61x67x65x3ax6cx69x6ex6bx
$hexStr = 'x' . substr($hexStr, 0, -2); // x73x74x6fx72x61x67x65x3ax6cx69x6ex6b

最终输出为:

x73x74x6fx72x61x67x65x3ax6cx69x6ex6b
^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^
hex hex hex hex hex hex hex hex hex hex hex hex

最新更新