jhartell/hexdump

PHP 的 Hexdump 工具

v0.2.0 2016-04-16 08:29 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:04:02 UTC


README

Build Status

jhartell/hexdump

PHP 的 Hexdump 工具。以类似 hexdump (hd) 命令行工具的格式打印二进制数据。当调试套接字通信或处理二进制文件时非常有用。

安装

使用以下命令安装最新版本

$ composer require jhartell/hexdump

用法

<?php
use Jhartell\Hexdump\Hexdump;
$hexdump = new Hexdump();
$data = "This is a string with non-printable \x05\x10 characters\x00";
?>
<pre>
<?php echo $hexdump->dump($data); ?>
</pre>

这将以默认的 Hex+ASCII 格式输出数据。

00000000  54 68 69 73 20 69 73 20  61 20 73 74 72 69 6e 67  |This is a string|
00000010  20 77 69 74 68 20 6e 6f  6e 2d 70 72 69 6e 74 61  | with non-printa|
00000020  62 6c 65 20 05 10 20 63  68 61 72 61 63 74 65 72  |ble .. character|
00000030  73 00                                             |s.|
00000032