将十六进制转换为ASCII字符 [英] Convert hex to ascii characters
本文介绍了将十六进制转换为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
.
编辑:我没有仔细阅读:)基地16到基地62仍然非常可行,如上所述。
I had not read carefully enough :) Base 16 to base 62 is still very doable, as above.
看到它有效 。
See it in action.
这篇关于将十六进制转换为ASCII字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文