Convert hex to ascii characters

前端 未结 5 1079
攒了一身酷
攒了一身酷 2020-12-03 15:12

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?

5条回答
  •  囚心锁ツ
    2020-12-03 15:28

    You mean want to convert a string of hex digits into actual hex values?

    $hex_string = "A1B2C3D4F5"; // 10 chars/bytes
    $packed_string = pack('H*', $hex_string); // 0xA1B2C3D4F5 // 5 chars/bytes.
    

提交回复
热议问题