将十六进制转换为 ascii 字符 [英] Convert hex to ascii characters

查看:66
本文介绍了将十六进制转换为 ascii 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用一个0-9a-zA-Z字符的序列来表示一个十六进制字符(0-9A-F)的序列,所以结果序列更小,可以解码?

Is it possible to represent a sequence of hex characters (0-9A-F) with a sequence of 0-9a-zA-Z characters, so the the result sequence is smaller and can be decoded?

例如:

$hex = '5d41402abc4b2a76b9719d911017c592';
echo $string = encode($hex); // someASCIIletters123
echo decode(string) == $hex; //true

推荐答案

你可以简单地调整我提出的解决方案 此处 使用函数base_convert_arbitrary.

You can trivially adapt the solution I presented here using the function base_convert_arbitrary.

我没有仔细阅读:) Base 16 到 base 62 仍然非常可行,如上所述.

I had not read carefully enough :) Base 16 to base 62 is still very doable, as above.

查看实际操作.

这篇关于将十六进制转换为 ascii 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆