# an exemple of file description of binary data to generate
# set endianess to big-endian
big-endian
# default number is hexadecimal
00112233
# man can explicit a number type: %b means binary number
%b0100110111100000
# change endianess to little-endian
little-endian
# if no explicit, use default
44556677
# bytes are not concerned by endianess
88 99 aa bb
# change default to decimal
decimal
# following number is now decimal
0123
# strings are delimited by " or '
"this is some raw string"
# explicit hexa number starts with %x
%xff
3条答案
按热度按时间lnlaulya1#
使用
xxd -r
。它将十六进制转储恢复为其二进制表示形式。source和source
编辑:
-p
参数也非常有用。它接受“纯”十六进制值,但忽略空格和行更改。因此,如果您有一个如下所示的纯文本转储:
您可以使用以下命令将其转换为二进制:
然后使用如下内容获得有用的输出:
06odsfpq2#
如果您有长文本或文件中的文本,您还可以使用binmake工具,该工具允许您以文本格式描述一些二进制数据并生成一个二进制文件(或输出到stdout)。它允许更改字符顺序和数字格式,并接受注解。
其默认格式为十六进制,但不限于此。
首先获取并编译binmake:
您可以使用
stdin
和stdout
对其进行管道连接:或者使用文件。因此,创建文本文件
file.txt
:生成二进制文件
file.bin
:5ktev3wc3#
除了
xxd
之外,您还应该查看包/命令od
和hexdump
。它们都是相似的,但每个都提供了略微不同的选项,使您可以根据需要定制输出。例如,hexdump -C
是具有关联的ASCII转换的传统六进制转储。